Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 710
Tofiq Samali Avatar asked Dec 22 '19 17:12

Tofiq Samali


People also ask

What are the font family available in Flutter?

The default font of MaterialApp is roboto , a Google font. Show activity on this post. The default fonts depend on the operating system: Android uses the Roboto font.


2 Answers

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

like image 103
dhanasekar Avatar answered Sep 28 '22 10:09

dhanasekar


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.

like image 44
Uday Chauhan Avatar answered Sep 28 '22 11:09

Uday Chauhan