0x4b50
0x4b50

Reputation: 679

How to set app wide fontSize for Text elements in Flutter?

How can I set an app wide fontSize in Flutter?

Currently I have a TextStyle as follows

const TextStyle myTextStyle = TextStyle(fontSize: 18);

But I have to set it for every Text() Widget manually.

Upvotes: 0

Views: 1880

Answers (1)

Code Poet
Code Poet

Reputation: 8033

Look here: https://flutter.dev/docs/cookbook/design/themes

MaterialApp(
  title: title,
  theme: ThemeData(
    // Define the default brightness and colors.
    brightness: Brightness.dark,
    primaryColor: Colors.lightBlue[800],
    accentColor: Colors.cyan[600],

    // Define the default font family.
    fontFamily: 'Georgia',

    // Define the default TextTheme. Use this to specify the default
    // text styling for headlines, titles, bodies of text, and more.
    textTheme: TextTheme(
      headline1: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
      headline6: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
      bodyText2: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
    ),
  )
);

Upvotes: 4

Related Questions