Reputation: 935
I have an issue with my flutter app.
I use 2 physical devices
Android: A20 Iphone: Iphone 11
I setup fontsize but the font size on the iPhone is not fulfilled.
Please find below: the screens from both devices.
How can I fix this difference?
IPhone 11
Android
Material app
GetMaterialApp(
title: L.localize('Wetip'),
debugShowCheckedModeBanner: false,
navigatorKey: navigatorKey,
theme: ThemeData(
primarySwatch:
PaletteGenerator.generateMaterialColor(MyTheme.PrimaryColor),
primaryColor: MyTheme.PrimaryColor,
accentColor: MyTheme.SecondaryColor,
textTheme: GoogleFonts.ralewayTextTheme(),
disabledColor: Colors.grey.withOpacity(0.5),
errorColor: MyTheme.PrimaryColor,
visualDensity: VisualDensity.adaptivePlatformDensity
),
home: MyApp())
The textformfield
TextFormField(
style: TextStyle(
fontSize: 16,
color: colorText != null ? colorText : Colors.black,
decorationColor: Colors.black),
Et mon titleSection
Widget TitleSection(String text, {color = Colors.white, TextStyle?
style}) { return Text( text, textAlign: TextAlign.center, style: style == null ? TextStyle( color: color, fontSize: Theme.of(navigatorKey.currentContext!) .textTheme .headline4! .fontSize) : style, ); }
Upvotes: 1
Views: 3343
Reputation: 21
I prefer Sizer Package for auto scaling of fonts
First you have to wrap materialApp with Responsive Sizer widget
ResponsiveSizer(
builder: (context, orientation, deviceType) {
return MaterialApp();
}
)
Then you can use font size like below
Text(
'Sizer',style: TextStyle(fontSize: 15.sp),
);
Upvotes: 1
Reputation: 1164
This was explained in the GoogleIO presentation you can try their solution.
MaterialApp(
builder: (context, child) {
return MediaQuery(
child: child,
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
);
},
)
Setting the MediaQuery.textScaleFactorOf(context)
should also help
eg. fontSize: 18 * MediaQuery.textScaleFactorOf(context),
Upvotes: 0