Limit system device font size scale, with textScaleFactor

Does anyone know if I can add a code that limits the font size of my entire application between two factors ( textScaleFactor ). I have the following code, but I want to add it as a start custom action. The problem is that I need the context, and FF doesn't allow adding custom actions to the start with variables or context.

return MaterialApp(

builder: (context, child) {

final mediaQueryData = MediaQuery.of(context);

final scale = mediaQueryData.textScaleFactor.clamp(1.0, 1.3);

return MediaQuery(

child: child,

data: MediaQuery.of(context).copyWith(textScaleFactor: scale),

);

},

);

// Here I have set the limit of the system scaling factor between 1.0 and 1.3

9
5 replies