flutterfont-size

flutter: how to set font size larger (bigger)


TextStyle(fontSize: 16)

Is there a way to set fontSize bigger than normal instead of hard-coded size? For web:

font-size: larger

Solution

  • You can use default text sizes of the Theme:

    Text('Hi There', style: Theme.of(context).textTheme.titleLarge)
    

    There are different textTheme Text Styles like:

    TextStyle? displayLarge,
    TextStyle? displayMedium,
    TextStyle? displaySmall,
    TextStyle? headlineLarge,
    TextStyle? headlineMedium,
    TextStyle? headlineSmall,
    TextStyle? titleLarge,
    TextStyle? titleMedium,
    TextStyle? titleSmall,
    TextStyle? bodyLarge,
    TextStyle? bodyMedium,
    TextStyle? bodySmall,
    TextStyle? labelLarge,
    TextStyle? labelMedium,
    TextStyle? labelSmall,
    

    Each of the above Text Style has a different font size.

    If textTheme is not applied in your ThemeData, defaults will be applied.

    Hope it helps you.