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)
);
}
}
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.
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
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.
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.
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
If your app is running on the emulator or device just stop it and relaunch it again it solves your problem
The author of font_awesome_flutter
package suggests the following steps for anyone who has icons not showing problem:
Also make sure to set uses-material-design
to true
in pubspec.yaml file.
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:
Stop main.dart
(Android Emulator)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With