From 0cea2bb229b9091c29e5df6e1c7b4bb10d421766 Mon Sep 17 00:00:00 2001 From: David Armstrong Date: Wed, 19 Feb 2020 01:46:30 +0000 Subject: [PATCH 1/2] Added groupScaleFactor property --- lib/src/auto_size_text.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/auto_size_text.dart b/lib/src/auto_size_text.dart index 4146caa..e48ff60 100644 --- a/lib/src/auto_size_text.dart +++ b/lib/src/auto_size_text.dart @@ -31,6 +31,7 @@ class AutoSizeText extends StatefulWidget { this.textScaleFactor, this.maxLines, this.semanticsLabel, + this.groupScaleFactor = 1, }) : assert(data != null, 'A non-null String must be provided to a AutoSizeText widget.'), textSpan = null, @@ -58,6 +59,7 @@ class AutoSizeText extends StatefulWidget { this.textScaleFactor, this.maxLines, this.semanticsLabel, + this.groupScaleFactor = 1, }) : assert(textSpan != null, 'A non-null TextSpan must be provided to a AutoSizeText.rich widget.'), data = null, @@ -216,6 +218,10 @@ class AutoSizeText extends StatefulWidget { /// ``` final String semanticsLabel; + /// This property scales the text size of this element in the group relative + /// to other elements + final double groupScaleFactor; + @override _AutoSizeTextState createState() => _AutoSizeTextState(); } @@ -264,8 +270,9 @@ class _AutoSizeTextState extends State { Widget text; if (widget.group != null) { - widget.group._updateFontSize(this, fontSize); - text = _buildText(widget.group._fontSize, style, maxLines); + widget.group._updateFontSize(this, fontSize / widget.groupScaleFactor); + text = _buildText( + widget.group._fontSize * widget.groupScaleFactor, style, maxLines); } else { text = _buildText(fontSize, style, maxLines); } From 5f62a5a1d68e9a39bfb7859f75e70aef49bcc9ba Mon Sep 17 00:00:00 2001 From: David Armstrong Date: Fri, 21 Feb 2020 01:09:30 +0000 Subject: [PATCH 2/2] Updated README to include groupScaleFactor --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 35d2547..b692da2 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ But it does not mean that all `TextSpan`s have at least font size `5`. | `textScaleFactor`* | The number of font pixels for each logical pixel. Also affects `minFontSize`, `maxFontSize` and `presetFontSizes`. | | `maxLines` | An optional maximum number of lines for the text to span. | | `semanticsLabel`* | An alternative semantics label for this text. | +| `groupScaleFactor` | The factor by which font should be scaled relative to the other elements in the same group. | Parameters marked with \* behave exactly the same as in `Text`