-
I can not find a way to pass my custom TextStyle in FlexColorScheme. For example, ThemeData has argument textTheme:
Could you please let me know how I can add custom text style to Theme? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @PTLam25 thanks for your question. Yes it is a bit tricky actually to add custom text theme. Basically you have to do the same steps as when you already have a For more details please see this issue and details there: #15 To help out with this frequently asked question (and I want the feature too 😃 ), I am adding and exposing The feature will make it a lot simpler, since you can then just pass in the from default modified However to do it right now, the link above should help you with some examples. The solution is basically the same hoops you have to go through when you want modify text theme of a Hope this helps, let me know if you need any more assistance with it. |
Beta Was this translation helpful? Give feedback.
-
with your example // Light theme with custom text theme
final ThemeData myLightTheme = FlexColorScheme.light().toTheme().copyWith(textTheme: const TextTheme(
bodyText1: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w700,
),
bodyText2: TextStyle(
fontSize: 16.0,
),
headline2: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
),
headline1: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w700,
),
subtitle2: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w700,
),
headline6: TextStyle(
fontSize: 36,
fontWeight: FontWeight.w700,
),
),
).merge(Typography.material2018(platform: defaultTargetPlatform).black), |
Beta Was this translation helpful? Give feedback.
-
In the next version 4.0.0 you will be able to do this: // Custom text theme
const TextTheme customText = const TextTheme(
bodyText1: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w700,
),
bodyText2: TextStyle(
fontSize: 16.0,
),
headline2: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
),
headline1: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w700,
),
subtitle2: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w700,
),
headline6: TextStyle(
fontSize: 36,
fontWeight: FontWeight.w700,
),
);
// Light theme with custom text theme
final ThemeData myLightTheme= FlexColorScheme.light(
textTheme: customText,
).toTheme;
// Also a new syntax via an extension available, you can you use e.g.
// FlexThemeData.dark and don't need to do a .toTheme from the FlexColorScheme.dark
final ThemeData myDarkTheme= FlexThemeData.dark(
textTheme: customText,
); Should be much simpler and nicer to use. |
Beta Was this translation helpful? Give feedback.
-
@rydmike thank you very much for your detailed explanation. |
Beta Was this translation helpful? Give feedback.
In the next version 4.0.0 you will be able to do this: