Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter cannot use Google fonts in text

When I try to use google_fonts I get an error like this. I also imported the library and added " google_fonts: ^3.0.1" to the "pub.yml" file.
" I added.

Console error image

Code line error image

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

void main() {
  runApp(BenimUyg());
}

class BenimUyg extends StatelessWidget {
  const BenimUyg({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        backgroundColor: Colors.brown[300],
        body: SafeArea(
          child: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: const <Widget>[
                CircleAvatar(
                  backgroundColor: Colors.lime,
                  backgroundImage: AssetImage("assets/images/kahve.jpg"),
                  radius: 70,
                ),
                Text(
                  "Flutter Kahvecisi",
                  style: TextStyle(
                    fontSize: 40,
                    fontFamily: "Courgette",
                    color: Colors.brown,
                  ),
                ),
                // ignore: unnecessary_const
                Text(
                  "Çok Yakındasınız",
                  style: GoogleFonts.pacifico(
                    textStyle: TextStyle(
                      color: Colors.lime,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

>Solution :

The issue is coming from children: const <Widget>[ remove const.

 child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[ // here
                CircleAvatar(
                  backgroundColor: Colors.lime,
                  backgroundImage: AssetImage("assets/images/kahve.jpg"),
                  radius: 70,
                ),
class BenimUyg extends StatelessWidget {
  const BenimUyg({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        backgroundColor: Colors.brown[300],
        body: SafeArea(
          child: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                const CircleAvatar(
                  backgroundColor: Colors.lime,
                  backgroundImage: AssetImage("assets/images/kahve.jpg"),
                  radius: 70,
                ),
                const Text(
                  "Flutter Kahvecisi",
                  style: TextStyle(
                    fontSize: 40,
                    fontFamily: "Courgette",
                    color: Colors.brown,
                  ),
                ),
                // ignore: unnecessary_const
                Text(
                  "Çok Yakındasınız",
                  style: GoogleFonts.pacifico(
                    textStyle: const TextStyle(
                      color: Colors.lime,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading