Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions demo/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ 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'
}

defaultConfig {
applicationId "com.github.leisim.auto_size_text.demo"
minSdkVersion 16
targetSdkVersion 27
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName 'v1'
}
Expand Down
1 change: 1 addition & 0 deletions demo/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:icon="@drawable/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.github.leisim.auto_size_text.demo;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
GeneratedPluginRegistrant.registerWith(this.getFlutterEngine());
}
}
2 changes: 1 addition & 1 deletion demo/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand Down
1 change: 1 addition & 0 deletions demo/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
3 changes: 1 addition & 2 deletions demo/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 changes: 1 addition & 6 deletions demo/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class App extends StatelessWidget {
DeviceOrientation.landscapeRight,
]);

SystemChrome.setEnabledSystemUIOverlays([]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);

return MaterialApp(
theme: ThemeData.light(),
Expand Down Expand Up @@ -133,11 +133,6 @@ class _DemoAppState extends State<DemoApp> {
title: Text('preset'),
activeColor: colors[4],
),
BottomNavyBarItem(
icon: Icon(MdiIcons.stackOverflow),
title: Text('replacement'),
activeColor: colors[5],
),
],
),
);
Expand Down
12 changes: 6 additions & 6 deletions demo/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
publish_to: none
14 changes: 7 additions & 7 deletions lib/src/auto_size_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -314,8 +314,7 @@ class _AutoSizeTextState extends State<AutoSizeText> {
recognizer: widget.textSpan?.recognizer,
);

final userScale =
widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context);
final userScale = widget.textScaleFactor ?? 1.0;

int left;
int right;
Expand All @@ -325,6 +324,7 @@ class _AutoSizeTextState extends State<AutoSizeText> {
final num defaultFontSize =
style!.fontSize!.clamp(widget.minFontSize, widget.maxFontSize);
final defaultScale = defaultFontSize * userScale / style.fontSize!;

if (_checkTextFits(span, defaultScale, maxLines, size)) {
return <Object>[defaultFontSize * userScale, true];
}
Expand Down Expand Up @@ -379,7 +379,7 @@ class _AutoSizeTextState extends State<AutoSizeText> {
),
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,
Expand All @@ -397,7 +397,7 @@ class _AutoSizeTextState extends State<AutoSizeText> {
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,
Expand All @@ -422,7 +422,7 @@ class _AutoSizeTextState extends State<AutoSizeText> {
locale: widget.locale,
softWrap: widget.softWrap,
overflow: widget.overflow,
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
Expand All @@ -437,7 +437,7 @@ class _AutoSizeTextState extends State<AutoSizeText> {
locale: widget.locale,
softWrap: widget.softWrap,
overflow: widget.overflow,
textScaleFactor: fontSize / style.fontSize!,
textScaler: TextScaler.linear(fontSize / style.fontSize!),
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -13,4 +13,4 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: '>=1.11.1 <3.0.0'
lints: ^4.0.0