Correct way to set a custom TextTheme? #83
-
I'd like to know the current way of adding a text theme. FlexThemeData.light(
textTheme: GoogleFonts.interTextTheme(),
primaryTextTheme: GoogleFonts.interTextTheme(),
); or FlexThemeData.light(
typography: Typography.material2021(
platform: Theme.of(context).platform,
white: GoogleFonts.interTextTheme(),
black: GoogleFonts.interTextTheme(),
),
); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I use and recommend the first version. When you use the 1st version you can get the optional color blended theming also on your provided custom text themes, that FCS component themes can apply if you want it. With 2nd version that would not be applied. (Or so I think, I have actually never tried the 2nd way) A similar situation also applies to By default when you in FCS opt-in on Material3 you get 2021 Typography, else M2 2018. You can set it to e.g. 2021 for both modes like this, if you like: FlexThemeData.light(
textTheme: GoogleFonts.interTextTheme(),
primaryTextTheme: GoogleFonts.interTextTheme(),
typography: Typography.material2021(
platform: defaultTargetPlatform,
),
); To use By using All the FCS examples, even example 5, the Themes Playground, use |
Beta Was this translation helpful? Give feedback.
I use and recommend the first version.
When you use the 1st version you can get the optional color blended theming also on your provided custom text themes, that FCS component themes can apply if you want it. With 2nd version that would not be applied. (Or so I think, I have actually never tried the 2nd way)
A similar situation also applies to
ThemeData
, it is better to not mixing in the customTextTheme
into theTypography
. TheThemeData
factory does config on passed intextTheme
too (FCS replicates it, plus some extras if opted in on them) that might break if you set it viatypography
property. Although I must admit, I have as mentioned never tested doing it that way.By default when yo…