Component - Custom fonts
This Flutter UI component shows how to use a custom font in a text widget. It changes the default font style to a unique font loaded from the app's assets, making the text look different and personalized.
This Flutter UI component shows how to use a custom font in a text widget. It changes the default font style to a unique font loaded from the app's assets, making the text look different and personalized.
Scaffold
├── AppBar
│ └── Text
└── Center
└── Textfonts:
- family: CoolFont
fonts:
- asset: assets/fonts/CoolFont-Regular.ttf
- asset: assets/fonts/CoolFont-Bold.ttf
weight: 700
What will this code display?
Text('Hi', style: TextStyle(fontFamily: 'CoolFont', fontWeight: FontWeight.bold))pubspec.yaml:
fonts:
- family: FancyFont
fonts:
- asset: assets/fonts/FancyFont.ttf
Dart code:
Text('Hello', style: TextStyle(fontFamily: 'FancyFontt'))Pass the test and this pattern moves unknown