simc / auto_size_text

Flutter widget that automatically resizes text to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text
MIT License
2.03k stars 235 forks source link

Allow for individual scale factor in a group #47

Open davystrong opened 4 years ago

davystrong commented 4 years ago

I am having a problem were I am using two different font families that I would like to automatically resize together, so I put them both in the same group. However, one of the fonts looks smaller than the other, using the same font size. I would like to be able to set a scale factor for one that wouldn't affect the other. Both of them would still resize at the same time but they would always maintain the same ratio. I tried using textScaleFactor, however this doesn't seem to be independent: the second widget seems to use the same textScaleFactor as the first.

davystrong commented 4 years ago

If I modify the build function of _AutoSizeTextState like this:

if (widget.group != null) {
   widget.group._updateFontSize(this, fontSize / widget.factor);
   text =
      _buildText(widget.group._fontSize * widget.factor, style, maxLines);
}

(adding factor in the constructor), it does exactly what I want. I could work on a PR but I imagine that this overlaps with the expected functionality of textScaleFactor. Should it be changed or should a new parameter be added (if you think this is useful)?

davystrong commented 4 years ago

I decided to create a new parameter groupScaleFactor as textScaleFactor seems to be linked to accessibility.