Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #47 #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
11 changes: 9 additions & 2 deletions lib/src/auto_size_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -264,8 +270,9 @@ class _AutoSizeTextState extends State<AutoSizeText> {
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);
}
Expand Down