Flutter Tips #3

Ever needed to rush a design and not have to worry about how the application handles text scaling? Well you can easily do that with one widget in Flutter.

Note once you’re moving out of POC stage; it really should be removed. However this little widget will help prevent your designs breaking across different users when they have changes their accessibility settings.

class PreventTextScalingWidget extends StatelessWidget {
  const PreventTextScalingWidget({
    required this.child,
  });

  final Widget child;

  @override
  Widget build(BuildContext context) {
    final MediaQueryData data = MediaQuery.of(context);
    return MediaQuery(
      data: data.copyWith(
        boldText: false,
        textScaleFactor: 1.0,
      ),
      child: child,
    );
  }
}

Before you go to the store, there is a risk your iOS app may be declined for adding this, so bare that in mind. It is rare and I have left it “accidentally” on in plenty of apps over the years. However you really shouldn’t!

That’s all for this one. See you soon!
Ryan

Previous
Previous

Featured Flutter Package - Spider

Next
Next

Flutter Tips #2