Reputation: 73
I am trying to scale my fonts so that they look the same on different screen sizes, large or small. I have the code below, which is linked to an underlying theme (flutter standard theme). I have tried manually changing the fontsize but this does not help since it looks different on all screen sizes.
Is there a recommended way to auto-scale fontsize depending on screen size?
Expanded(
child: Column(
children: <Widget>[
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/50)),
Text("We're finding your pizza!",
textAlign: TextAlign.center,
style: theme.textTheme.title.copyWith(fontSize: 26),
),
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/40)),
Text(
"We'll notify you when we've found one.",
textAlign: TextAlign.center,
style: theme.textTheme.title),
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/40)),
Text(
"Estimated wait time:",
textAlign: TextAlign.center,
style: theme.textTheme.title),
Padding(padding: EdgeInsets.all(MediaQuery.of(context).size.height/80)),
Text(
"< 1 minute.",
textAlign: TextAlign.center,
style: theme.textTheme.title,
)],
),
),
Upvotes: 0
Views: 94
Reputation: 1165
You can try auto_size_text
Installing
add this to your pubspec.yaml
auto_size_text: ^2.1.0
Usage
AutoSizeText(
'Your auto size text',
style: TextStyle(fontSize: 20),//minimum font size
maxLines: 2,//if needed
)
Upvotes: 1