textScaleFactor was recently deprecated and one is supposed to use the TextScaler.scale(double fontSize) instead, but not all places that take a textScaleFactor seemingly supports the new way.
For example ButtonStyleButton.scaledPadding is taking in a textScaleFactor, but what fontSize are you supposed to call TextScalar.scale with to pass in as the scale factor there?
ButtonStyleButton.scaledPadding(
const EdgeInsets.symmetric(horizontal: 16),
const EdgeInsets.symmetric(horizontal: 8),
const EdgeInsets.symmetric(horizontal: 4),
MediaQuery.maybeOf(context)?.textScaler.scale(??),
);
Previously:
ButtonStyleButton.scaledPadding(
const EdgeInsets.symmetric(horizontal: 16),
const EdgeInsets.symmetric(horizontal: 8),
const EdgeInsets.symmetric(horizontal: 4),
MediaQuery.maybeOf(context)?.textScaleFactor,
);
The scale method of TextScaler takes your fontSize and scales it with the text scale factor.
That means if you pass it 1, it will return the textScaleFactor.
Before
double textScaleFactor = MediaQuery.of(context).textScaleFactor;
After
double textScaleFactor = MediaQuery.textScalerOf(context).scale(1);
I have same problem. For the alternative maybe we can do this
final textScaleFactor = TextScaler.scale(10) / 10;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With