flutter: Custom font showing no effect
Solution 1
I think its to do with your pubspec file, the indentation matters.
flutter:
uses-material-design: true
assets:
- image/lake.png
fonts:
- family: Raleway
fonts:
- asset: fonts/Raleway-Regular.ttf
- asset: fonts/Raleway-Italic.ttf
style: italic
Solution 2
I actually used this exact font in my application as well. I think you need to buy a license for it, but I don't remember for sure. Anyways, the name of you font is here:
fonts:
family: Raleway
Here, you named the the font Raleway, so in your Flutter code, you must specify the exact same name:
fontFamily: 'Raleway'
Solution 3
You named your font family Raleway
but used the string Raleway-Regular
in your code. Change one of these to the other and it should work.
![Farhana Naaz Ansari](https://i.stack.imgur.com/tutNS.jpg?s=256&g=1)
Farhana Naaz Ansari
Farhana... The only way of writing fewer bugs is writing less code.
Updated on December 08, 2022Comments
-
Farhana Naaz Ansari over 1 year
I tried many solutions on SO but none of them are working, I try these solutions here,here but still font showing no effect and app is not showing any error. what is wrong with the code.
this is my code below
Widget textSection = new Container( decoration: new BoxDecoration( color: Colors.blue[100], border: new Border.all(color: Colors.black)), padding: const EdgeInsets.all(18.0), margin: const EdgeInsets.only(left: 14.0, right: 14.0, bottom: 14.0), width: double.infinity, child: new Text( "Labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", textAlign: TextAlign.center, style: new TextStyle( color: Colors.black45, fontSize: 22.0, fontFamily: 'Raleway-Regular'), softWrap: true, ), );