zero.one
zero.one

Reputation: 1553

fontAwesome icons do not work inside my flutter app

I'm currently working on a side project and when I have included a font-awesome icon inside my app, it does not show up and instead, a blank box with two lines intersecting with each other like the letter x, how to fix this?

class ImageHoldingComponent extends StatefulWidget {
  @override
   _ImageHoldingComponentState createState() => 
 _ImageHoldingComponentState();

}

class _ImageHoldingComponentState extends State<ImageHoldingComponent> {
  @override
  Widget build(BuildContext context) {
    return Container(
   child: Icon(FontAwesomeIcons.python)
      );
  }
}

Upvotes: 12

Views: 25565

Answers (5)

Rafi
Rafi

Reputation: 53

Add font_awesome_flutter: ^10.3.0 package in pubspec.yaml file. Then use like this

    FaIcon(
           Icons.access_alarm,
           color: whatsappColor,
           size: 30,
          ),

Upvotes: 0

Serhat GEN&#199;
Serhat GEN&#199;

Reputation: 5

Just save the from pupspec.yaml file under dependices and say pub get, don't forget to import it

Upvotes: 0

Muzammil
Muzammil

Reputation: 768

If your app is running on the emulator or device just stop it and relaunch it again it solves your problem

Upvotes: 3

Trinh Hieu
Trinh Hieu

Reputation: 805

This happens when you start using the older version of font_awesome_flutter and because the virtual device cache is stored when you build the Flutter app, so every time you change the icon you have to stop the emulator and rebuild it.

My experience is:

  1. Stop main.dart (Android Emulator)

  2. In pubspec.yaml add (font_awesome_flutter) new version

font_awesome_flutter: ^8.8.1

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  font_awesome_flutter: ^8.8.1 //new verison

And Then click

"Pub get"

at the top of Flutter commands

  1. Run the emulator again (start main.dart)

Upvotes: 6

Mazin Ibrahim
Mazin Ibrahim

Reputation: 7889

The author of font_awesome_flutter package suggests the following steps for anyone who has icons not showing problem:

  1. Stopping the app
  2. Running flutter clean in your app directory
  3. Deleting the app from your simulator / emulator / device
  4. Rebuild & Deploy the app.

Also make sure to set uses-material-design to true in pubspec.yaml file.

Upvotes: 43

Related Questions