How to Change App Font
Customizing the font in your Flutter app enhances the user experience. Follow these steps to change the app font.
📂 Step 1: Add Your Font File
-
Navigate to the following directory in your project:
assets/fonts/
-
Copy and paste your new font files (
.ttf
or.otf
) into this folder.
📝 Step 2: Update pubspec.yaml
-
Open the
pubspec.yaml
file. -
Locate the fonts section and update it as follows:
flutter:
fonts:
- family: CustomFont
fonts:
- asset: assets/fonts/MyCustomFont.ttf
- Replace
CustomFont
with your desired font family name. - Replace
MyCustomFont.ttf
with the actual font file name.
🎨 Step 3: Apply the Font in Your Theme
-
Open your theme configuration file (e.g.,
theme.dart
). -
Set the new font family in
TextTheme
:ThemeData(
fontFamily: 'CustomFont',
);
⚡ Step 4: Apply Changes
-
Save the changes.
-
Run the following command to apply the changes:
flutter pub get
-
Restart the app to see the new font in action.
✅ Your app now has a new font! 🎨🚀