Google Fonts package Not working in flutter

2,934

Solution 1

It could be because of internet permission issue, google fonts using internet acces and if don't apply the permission in your project it won't work when you install the app.

for this you need to add follow line to file AndroidManifest.xml which is there; yourappname/android/app/src/debug/AndroidManifest.xml

and the line you will add:

<uses-permission android:name="android.permission.INTERNET"/>

Solution 2

I don't believe it is an internet problem. Most times fonts using Flutter packages contain an error in the Pubspec file.

Check your Pubspec.yaml file. Make sure your google fonts package is Formatted this way

version: 1.0.0+1
environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  google_fonts: ^1.1.0

flutter:
  assets:
    - google_fonts/ # you only need this line and nothing in the fonts area per https://pub.dev/packages/google_fonts 
Share:
2,934
sameer kashyap
Author by

sameer kashyap

Updated on December 17, 2022

Comments

  • sameer kashyap
    sameer kashyap over 1 year

    The google_fonts package is not working in the final build apk in FLutter, it works fine in the debug mode, but as soon as I build it and install the final apk, It just shows regular font.

  • NullByte08
    NullByte08 almost 4 years
    google_fonts package already contains the fonts and its installed in the local machine there is no need to use the internet to retrieve the fonts again.
  • Robertas
    Robertas over 3 years
    To download fonts over http, android.permission.INTERNET permission should be added to <app_dir>/android/app/src/main/AndroidManifest.xml as well.
  • Pathik Patel
    Pathik Patel almost 3 years
    I don't know why but this actually worked for me, on google_fonts: ^2.0.0 flutter: 2.2.0, in another project this permission isn't added, still working in that case. Anyway Thanks @Lunedor.
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
  • Chris
    Chris about 2 years
    Thanks! Doesn't help that they show this right at the bottom of the readme
  • MNBWorld
    MNBWorld about 2 years
    Brother thank you! That line worked for me. Please accept this answer as correct.