withNoTextScaling static method

Widget withNoTextScaling(
  1. {Key? key,
  2. required Widget child}

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.


static Widget withNoTextScaling({
  Key? key,
  required Widget child,
}) {
  return Builder(
    key: key,
    builder: (BuildContext context) {
      return MediaQuery(
        data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
        child: child,