I am using Getx for my state management. So When I Change MaterialApp to GetMaterialApp, the fontFamily switched back to the default.
pubspec.yaml file
flutter:
uses-material-design: true
fonts:
- family: Sen
fonts:
- asset: assets/fonts/Sen-Regular.ttf
weight: 300
- asset: assets/fonts/Sen-Bold.ttf
weight: 700
and I have saved Sen.ttf files in the assets/fonts folder
main.dart
Widget build(BuildContext context) {
return GetMaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSwatch().copyWith(
primary: kPrimaryColor,
secondary: kSecondaryColor,
),
fontFamily: "Sen"
)
debugShowCheckedModeBanner: false,
home: const MainScreen(),
);
}
If I switch back to MaterialApp font will work fine.
Any help will be appreciated, Thank You.
Once this happened to me while working with some google fonts. I tried different methods, there is nothing wrong with GetMaterialApp()
Option 1:
flutter clean
to clear all data, then update all the packages, and thenflutter pub get
Option 2: Initialy this is what I did. In the textTheme, add
TextStyle
for different types of text (headline1,bodyText1,etc)Option 3: If nothing works, try
flutter upgrade