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.06k stars 240 forks source link

Get Font Size #127

Open yosus opened 1 year ago

yosus commented 1 year ago

Would like a feature to get the font-size used after layout. This is so I can standardize the font-size in adjacent boxes (on same page)

GlobalKey  textKey = GlobalKey();
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {

   test.getActualFontSizeUsed();

});

// In build
Widget test =  AutoSizeText(
   'Trying to get Font Size',
   key: textKey,
);
Xazin commented 1 year ago

I think this would be quite easy to add support for, but I wonder if it wouldn't be better to have this in a callback instead, as it is calculated on build.

The way you would use this to "standardize the font-size" is a bit questionable to me, although I do understand the sentiment.

I'm just a user so I don't have much to say, whether it's a method or a callback. I wouldn't mind implementing it though.

hanskokx commented 1 year ago

I also would like this ability. I have a SizedBox containing my text. If the text resizes, I want the SizedBox to resize in proportion to the text size. Right now, I have no ability to do that.

raheel73 commented 1 year ago

I would also like to determine the adjusted font size. This is because I'm converting an AutoSizeText widget into a PDF Text widget, and I need to specify the exact font size after resizing.

raheel73 commented 1 year ago

I still want to get the resized font size