TextStyle(fontSize: 16)
Is there a way to set fontSize bigger than normal instead of hard-coded size? For web:
font-size: larger
TextStyle(fontSize: 16)
Is there a way to set fontSize bigger than normal instead of hard-coded size? For web:
font-size: larger
2
Answers
You can use default text sizes of the Theme:
There are different
textTheme
Text Styles like:Each of the above
Text Style
has a differentfont size
.If
textTheme
is not applied in yourThemeData
, defaults will be applied.Hope it helps you.
I think you are not want to give fontsize hardcoded into TestStyle like this,
instead, you want to do like this,
where larger is an int-typed variable where 16 is set.
For achieving your desired goal, you can do like this,
Then you can use it in TextStyle. But this way of using is not standard because globally declared things are not good practice. so that what you can do is, make a class where all of these values hold and use these value through that class,
Now you can use this class instance and provide your TestStyle fontsize through this class,
Also, you can create some pre-define TestStyle for re-using,
Again, you can create some extension that make better usability,
then you can give fontsize so much easily,
Now, you can do much more from here. You can make another extension on BuildContext where you can access this Theme and TextTheme for more better usability,
After that, you can use it like this,