withNoTextScaling static method
Wraps the child
in a MediaQuery with its MediaQueryData.textScaler
set to TextScaler.noScaling.
The returned widget must be inserted in a widget tree below an existing MediaQuery widget.
This can be used to prevent, for example, icon fonts from scaling as the user adjusts the platform's text scaling value.
Implementation
static Widget withNoTextScaling({
Key? key,
required Widget child,
}) {
return Builder(
key: key,
builder: (BuildContext context) {
assert(debugCheckHasMediaQuery(context));
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
child: child,
);
},
);
}