-
I'm trying to set different FamilyFonts for different Locales, when I try to use the lightFlexTheme.copyWith(fontFamily: desiredFont) I get an error that says 'fontFamily' is not defined.
am I not using it correctly ? is there a workaround for this ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @GitGud31, Thanks for your question. It is a good one and The observation and analyzer is of course correct, and even expected. There is no The line: final lightFlexTheme = FlexThemeData.light(..); Returns a This can feel confusing, since the The In the In the resulting Be aware that there are many caveats when working with I suggest reading this Q&A answer to get up to speed on most of the Hope this helps 😄 and happy theming! BR PS. Converting this issue to a Q/A question as well. Maybe it will help others some day too if they find it there. |
Beta Was this translation helpful? Give feedback.
-
Hope, it will help someone: @override
Widget build(BuildContext context) {
final ThemeData darkThemeData = FlexThemeData.dark(
colorScheme: FlexThemeData.dark(scheme: FlexScheme.flutterDash).colorScheme.copyWith(),
fontFamily: GoogleFonts.rubik().fontFamily,
);
final ThemeData lightThemeData = FlexThemeData.light(
colorScheme: FlexThemeData.light(scheme: FlexScheme.flutterDash).colorScheme.copyWith(),
fontFamily: GoogleFonts.rubik().fontFamily,
);
return GetMaterialApp(
title: 'Atlas',
initialRoute: '/welcome',
theme: lightThemeData,
darkTheme: darkThemeData,
themeMode: ThemeMode.light,
builder: (context, child) => _getScaledPage(context, child),
getPages: [
GetPage(name: '/welcome', page: () => const Welcome()),
GetPage(name: '/sign-in', page: () => SignInPage()),
GetPage(name: '/home', page: () => const HomePage()),
],
);
} |
Beta Was this translation helpful? Give feedback.
Hi @GitGud31,
Thanks for your question. It is a good one and
fontFamily
can indeed be confusing. Let me try to explain why.The observation and analyzer is of course correct, and even expected. There is no
fontFamily
property in yourlightFlexTheme
since it is aThemeData
object.The line:
Returns a
ThemeData
object andThemeData
object does not have a propertyfontFamily
. This is a feature of Flutter SDK, not FlexColorScheme.This can feel confusing, since the
ThemeData()
factory has afontFamily
parameter (and for convenience, so doesFlexThemeData
or actually theFlexColorScheme
class it uses), but the producedThemeData
object does not h…