TextScaleFactor for TextField in Flutter?
1,483
You can wrap it with a MediaQuery
with a custom textScaleFactor
Widget build(BuildContext context) {
final mqData = MediaQuery.of(context);
final mqDataNew = mqData.copyWith(textScaleFactor: mqData.textScaleFactor > 5.0 ? 5.0 : mqData.textScaleFactor)
return MediaQuery(data: mqDataNew, child: TextField());
}
The TextField
does not need to be a direct child of MediaQuery
.
Author by
Caleb Hatcher
Updated on December 09, 2022Comments
-
Caleb Hatcher over 1 year
Was wondering is there a way to control textscalefactor for TextField widget in flutter. Basically I want to limit a text field from growing too large when a user increase font/text size in their devices accessibility settings.
Thanks.