'The Google Fonts Package in Flutter app is not working

First, I added the google_fonts package to your pubspec dependencies.

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  google_fonts: ^0.2.0

Then

import 'package:google_fonts/google_fonts.dart';

and apply to a Text widget

        Text(
          'This is Google Fonts',
          style: GoogleFonts.lato(fontSize: 40),
        ),
        Text(
          'This is Google Fonts',
          style: GoogleFonts.adventPro(fontSize: 40),
        ),

enter image description here



Solution 1:[1]

Please check internet connection- your emulator does not have internet connectivity. google fonts need internet connection on device/emulator.

Solution 2:[2]

After adding the dependency pubspec.yaml file

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  google_fonts: ^0.2.0

run the command in terminal\cmd console as :

> flutter packages get 

this will fetch the dependency into your workspace.

Solution 3:[3]

I fixed mine by deleting the emulator and installing a new one. My older emulator was not connecting to the internet for some reason and reinstalling it fixed it for me.

Solution 4:[4]

Unless you store the fonts in your assets, you need to define explicitly that runtime fetching is enabled for Google Fonts:

GoogleFonts.config.allowRuntimeFetching = true;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dhanasekar
Solution 2 Uday Chauhan
Solution 3 Maruf Hassan
Solution 4 Agita