i would like to apply an application wide ScrollConfiguration
and also textScaleFactor
property.
I know, I can set the ScrollConfiguration
this way:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: const AuthGate(),
builder: (context, child) {
return ScrollConfiguration(
behavior: MyBehavior(),
child: child!,
);
},
);
}
and set the textScaleFactor
this way:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: const AuthGate(),
builder: (context, child) {
final mediaQueryData = MediaQuery.of(context);
return MediaQuery(
data: mediaQueryData.copyWith(textScaleFactor: 1.0),
child: child!,
);
},
);
}
My question is, how can i apply both?
Try this:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: const AuthGate(),
builder: (context, child) {
final mediaQueryData = MediaQuery.of(context);
return MediaQuery(
data: mediaQueryData.copyWith(textScaleFactor: 1.0),
child: ScrollConfiguration(
behavior: MyBehavior(),
child: child!,
),
);
},
);
}
But child property can be null, so pay attention about using null check there.