0

How do I set the text style to headline1 or body1 like it is described in the "Material Text Scale: Modernizing Flutter Text Theming" section of the Flutter 1.17 Announcement article

final TextStyle TEXT_STYLE = GoogleFonts.lato(textStyle: *something in here?*);
0

2 Answers 2

1

You can do this by creating a TextTheme object and using the available styles.

In your example:

final TextStyle TEXT_STYLE = GoogleFonts.lato(textStyle: TextTheme().bodyText1);
Sign up to request clarification or add additional context in comments.

Comments

0

The typographic style headline1 was deprecated after v3.1.0-0.0.pre in favour of displayLarge, while body1 in the Material Design specification was named bodyText1 in Flutter 1.17, but has also been deprecated in favour of displayLarge.

In your usecase with the Google Fonts library, to obtain a TextStyle you should use:

final TextStyle TEXT_STYLE = GoogleFonts.lato(textStyle: Theme.of(context).textTheme.displayLarge),

replacing displayLarge with your chosen theme size. The full list of sizes can be found within the documentation, but if you have overriden the TextTheme, you may not see the actual font size changes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.