2

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,
  ),
);

This is My yaml file

this is my project hierarchy

JJJ
  • 32,902
  • 20
  • 89
  • 102
Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105

3 Answers3

2

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
Jordan Davies
  • 9,925
  • 6
  • 40
  • 51
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'

Alex Jone
  • 292
  • 2
  • 14
1

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.