Understanding what default styles are used in a Flutter + Material app


Just starting out with Flutter + Material design. I notice that when a create a theme using ThemeData, if I use something like this:

  textTheme: TextTheme(bodyText1: TextStyle(color: Colors.white)),

It doesn’t seem to colour the text in a simple GridView with Text widgets with the colour white. However, if I change the above to use bodyText2 it does.

What is the logic behind bodyText2 being used for text across the app? Is there a good place to reference which text style names get used and why in a theming situation? Is this all just knowledge acquired through trial-and-error or are there some good catch-all rules for which styles get used in which circumstances?



I ran into the same issue and did some research on this.

As per the official documentation for Text :

The style argument is optional. When omitted, the text will use the style from the closest enclosing DefaultTextStyle.

And the explanation for bodyText2 in TextTheme:

The default text style for Material.

Now the answer is quite clear. If your Text widget does not have any explicitly given text style, and has no inherited text style from its ancestors in the way of placing a DefaultTextStyle at some nodes. Then it would use the value in bodyText2 from the theme.

Answered By – Evan

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *