diff --git a/demo/android/app/build.gradle b/demo/android/app/build.gradle index 73116aa..fee9f39 100644 --- a/demo/android/app/build.gradle +++ b/demo/android/app/build.gradle @@ -12,7 +12,8 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 27 + namespace 'com.github.leisim.auto_size_text.demo' + compileSdk 34 lintOptions { disable 'InvalidPackage' @@ -20,8 +21,8 @@ android { defaultConfig { applicationId "com.github.leisim.auto_size_text.demo" - minSdkVersion 16 - targetSdkVersion 27 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName 'v1' } diff --git a/demo/android/app/src/main/AndroidManifest.xml b/demo/android/app/src/main/AndroidManifest.xml index 1c5a59b..7810dc8 100644 --- a/demo/android/app/src/main/AndroidManifest.xml +++ b/demo/android/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ android:icon="@drawable/ic_launcher"> { title: Text('preset'), activeColor: colors[4], ), - BottomNavyBarItem( - icon: Icon(MdiIcons.stackOverflow), - title: Text('replacement'), - activeColor: colors[5], - ), ], ), ); diff --git a/demo/pubspec.yaml b/demo/pubspec.yaml index 9ad504a..f928fbf 100644 --- a/demo/pubspec.yaml +++ b/demo/pubspec.yaml @@ -1,10 +1,10 @@ name: demo description: AutoSizeText Demo App -version: 1.0.0+2 +version: 1.0.0+3 environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: ">=3.2.0 <4.0.0" dependencies: flutter: @@ -13,14 +13,14 @@ dependencies: auto_size_text: path: ../ - bottom_navy_bar: ^4.2.0 - material_design_icons_flutter: ^4.0.5755 + bottom_navy_bar: ^6.1.0 + material_design_icons_flutter: ^7.0.7296 dev_dependencies: - flutter_test: + flutter_test: sdk: flutter flutter: uses-material-design: true -publish_to: none \ No newline at end of file +publish_to: none diff --git a/lib/src/auto_size_text.dart b/lib/src/auto_size_text.dart index ec43838..eb48da0 100644 --- a/lib/src/auto_size_text.dart +++ b/lib/src/auto_size_text.dart @@ -184,7 +184,7 @@ class AutoSizeText extends StatefulWidget { /// This property also affects [minFontSize], [maxFontSize] and [presetFontSizes]. /// /// The value given to the constructor as textScaleFactor. If null, will - /// use the [MediaQueryData.textScaleFactor] obtained from the ambient + /// use [TextScaler] obtained from the ambient /// [MediaQuery], or 1.0 if there is no [MediaQuery] in scope. final double? textScaleFactor; @@ -314,8 +314,7 @@ class _AutoSizeTextState extends State { recognizer: widget.textSpan?.recognizer, ); - final userScale = - widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context); + final userScale = widget.textScaleFactor ?? 1.0; int left; int right; @@ -325,6 +324,7 @@ class _AutoSizeTextState extends State { final num defaultFontSize = style!.fontSize!.clamp(widget.minFontSize, widget.maxFontSize); final defaultScale = defaultFontSize * userScale / style.fontSize!; + if (_checkTextFits(span, defaultScale, maxLines, size)) { return [defaultFontSize * userScale, true]; } @@ -379,7 +379,7 @@ class _AutoSizeTextState extends State { ), textAlign: widget.textAlign ?? TextAlign.left, textDirection: widget.textDirection ?? TextDirection.ltr, - textScaleFactor: scale, + textScaler: TextScaler.linear(scale), maxLines: words.length, locale: widget.locale, strutStyle: widget.strutStyle, @@ -397,7 +397,7 @@ class _AutoSizeTextState extends State { text: text, textAlign: widget.textAlign ?? TextAlign.left, textDirection: widget.textDirection ?? TextDirection.ltr, - textScaleFactor: scale, + textScaler: TextScaler.linear(scale), maxLines: maxLines, locale: widget.locale, strutStyle: widget.strutStyle, @@ -422,7 +422,7 @@ class _AutoSizeTextState extends State { locale: widget.locale, softWrap: widget.softWrap, overflow: widget.overflow, - textScaleFactor: 1, + textScaler: TextScaler.noScaling, maxLines: maxLines, semanticsLabel: widget.semanticsLabel, ); @@ -437,7 +437,7 @@ class _AutoSizeTextState extends State { locale: widget.locale, softWrap: widget.softWrap, overflow: widget.overflow, - textScaleFactor: fontSize / style.fontSize!, + textScaler: TextScaler.linear(fontSize / style.fontSize!), maxLines: maxLines, semanticsLabel: widget.semanticsLabel, ); diff --git a/pubspec.yaml b/pubspec.yaml index 758bbdb..6396a74 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: auto_size_text description: Flutter widget that automatically resizes text to fit perfectly within its bounds. -version: 3.0.0 +version: 3.1.0 homepage: https://github.com/leisim/auto_size_text environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=3.2.0 <4.0.0" dependencies: flutter: @@ -13,4 +13,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: '>=1.11.1 <3.0.0' \ No newline at end of file + lints: ^4.0.0