Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
      );
  }
}
like image 361
Karrar Avatar asked Aug 08 '19 15:08

Karrar


People also ask

Why is my Font Awesome icon not showing Flutter?

If you're not seeing any icons at all, sometimes it means that Flutter has a cached version of the app on device and hasn't pushed the new fonts. I've run into that as well a few times... Please try: Stopping the app.

How to use Font Awesome icons in flutter?

Adding icon package in your flutter app 1. Create/Open a flutter project 2. Add font_awesome_flutter dependencies 3. Import it where icons are required from font awesome 4. Snippet code – How to use FaIcon widget in a flutter Complete Source code – font awesome icons example 1 Source code Font awesome icon output

How to add Font_Awesome_flutter in flutter?

Add font_awesome_flutter dependencies Now once your flutter project is read and completed with the gradle build process, then now it time to add the dependencies. then open pubspec.yamlfile, that you will find in project secton on the left side of your IDE. and app icon package dependencies dependencies: font_awesome_flutter: ^9.0.0 3.

Why are my icons not showing on Font Awesome 4?

Using any other won't work. For instance, if you try showing <i class="fas fa-user"></i> on Font Awesome 4, it won't get displayed. Note: Font Awesome allows you to add icons using ONLY <i> and <span> tags. If you use any other element they won't show. Only add your classes to either of the two.

Why are my icons not showing up in flutter?

The author of font_awesome_flutterpackage suggests the followingsteps for anyone who has icons not showing problem: Stopping the app Running flutter clean in your app directory


3 Answers

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

like image 111
Muzammil Avatar answered Oct 06 '22 04:10

Muzammil


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.

like image 44
Mazin Ibrahim Avatar answered Oct 06 '22 03:10

Mazin Ibrahim


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)
like image 35
Trinh Hieu Avatar answered Oct 06 '22 04:10

Trinh Hieu