Reputation: 19
I have done everything step bye step and it still says "undefined name 'Pacifico'"
pubspec file:
flutter:
uses-material-design: true
assets:
- images/
fonts:
- family: Pacifico
fonts:
- asset: fonts/Pacifico-Regular.ttf
It loads fine
main.dart
body: SafeArea(
child: Column(
children: <Widget>[
CircleAvatar(
radius: 50.0,
backgroundImage: AssetImage('images/me.2.png'),
),
Text(
"Ahmed",
style: TextStyle(
fontFamily: Pacifico,
//HERE IS THE PROBLEM!!
),
)
],
),
)),
Upvotes: 1
Views: 457
Reputation: 363
There are 2 possible solutions to check.
1. Make sure that your font's path is correct.
2. The way I use my fontFamily
is by adding them in my Theme
of my MaterialApp
or CupertinoApp
. By doing this you don't have to specifically type out the fontFamily
for each text
widget and I would assume that you are going to use this font
throughout the entire app
anyway.
MaterialApp(
title: 'My app',
theme: ThemeData(
fontFamily: 'Pacfico',
),
);
Upvotes: 3