Giter VIP home page Giter VIP logo

font_awesome_flutter's Introduction

font_awesome_flutter

Flutter Community: font_awesome_flutter

Pub

The free Font Awesome Icon pack available as set of Flutter Icons - based on font awesome version 6.5.1.

This icon pack includes only the free icons offered by Font Awesome out-of-the-box. If you have purchased the pro icons and want to enable support for them, please see the instructions below.

Installation

In the dependencies: section of your pubspec.yaml, add the following line:

dependencies:
  font_awesome_flutter: <latest_version>

Usage

import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class MyWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return IconButton(
      // Use the FaIcon Widget + FontAwesomeIcons class for the IconData
      icon: FaIcon(FontAwesomeIcons.gamepad), 
      onPressed: () { print("Pressed"); }
     );
  }
}

Icon names

Icon names equal those on the official website, but are written in lower camel case. If more than one icon style is available for an icon, the style name is used as prefix, except for "regular". Due to restrictions in dart, icons starting with numbers have those numbers written out.

Examples:

Icon name Code Style
angle-double-up FontAwesomeIcons.angleDoubleUp solid (this icon does not have other free styles)
arrow-alt-circle-up FontAwesomeIcons.arrowAltCircleUp regular
arrow-alt-circle-up FontAwesomeIcons.solidArrowAltCircleUp solid
1 FontAwesomeIcons.solidOne solid

Example App

View the Flutter app in the example directory to see all the available FontAwesomeIcons.

Customizing font awesome flutter

We supply a configurator tool to assist you with common customizations to this package. All options are interoperable. By default, if run without arguments and no icons.json in lib/fonts exists, it updates all icons to the newest free version of font awesome.

Setup

To use your custom version, you must first clone this repository to a location of your choice and run flutter pub get inside. This installs all dependencies.

The configurator is located in the util folder and can be started by running configurator.bat on Windows, or ./configurator.sh on linux and mac. All following examples use the .sh version, but work same for .bat. (If on windows, omit the ./ or replace it with .\.) An overview of available options can be viewed with ./configurator.sh --help.

To use your customized version in an app, go to the app's pubspec.yaml and add a dependency for font_awesome_flutter: '>= 4.7.0'. Then override the dependency's location:

dependencies:
  font_awesome_flutter: '>= 4.7.0'
  ...
  
dependency_overrides:
  font_awesome_flutter:
    path: path/to/your/font_awesome_flutter
  ...

Enable pro icons

❗ By importing pro icons you acknowledge that it is your obligation to keep these files private. This includes not uploading your package to a public github repository or other public file sharing services.

  • Go to the location of your custom font_awesome_flutter version (see setup)
  • Download the web version of font awesome pro and open it
  • Move all .ttf files from the webfonts directory and icons.json from metadata to path/to/your/font_awesome_flutter/lib/fonts. Replace existing files.
  • Run the configurator. It should say "Custom icons.json found"

It may be required to run flutter clean in apps who use this version for changes to appear.

Excluding styles

One or more styles can be excluded from all generation processes by passing them with the --exclude option:

$ ./configurator.sh --exclude solid
$ ./configurator.sh --exclude solid,brands

See the optimizations and dynamic icon retrieval by name sections for more information as to why it makes sense for your app.

Retrieve icons dynamically by their name or css class

Probably the most requested feature after support for pro icons is the ability to retrieve an icon by their name. This was previously not possible, because a mapping from name to icon would break all discussed optimizations. Please bear in mind that this is still the case. As all icons could theoretically be requested, none can be removed by flutter. It is strongly advised to only use this option in conjunction with a limited set of styles and with as few of them as possible. You may need to build your app with the --no-tree-shake-icons flag for it to succeed.

Using the new configurator tool, this is now an optional feature. Run the tool with the --dynamic flag to generate...

$ ./configurator.sh --dynamic

...and the following import to use the map. For normal icons, use faIconNameMapping with a key of this format: 'style icon-name'.

import 'package:font_awesome_flutter/name_icon_mapping.dart';

...
    FaIcon(faIconNameMapping['solid abacus']);
...

To exclude unused styles combine the configurator options:

$ ./configurator.sh --dynamic --exclude solid

A common use case also includes fetching css classes from a server. The utility function getIconFromCss() takes a string of classes and returns the icon which would be shown by a browser:

getIconFromCss('far custom-class fa-abacus'); // returns the abacus icon in regular style. custom-class is ignored

Duotone icons

Duotone support has been discontinued after font awesome changed the way they lay out the icon glyphs inside the font's file. The new way using ligatures is not supported by flutter at the moment.

For more information on why duotone icon support was discontinued, see this comment.

FAQ

Why aren't the icons aligned properly or why are the icons being cut off?

Please use the `FaIcon` widget provided by the library instead of the `Icon` widget provided by Flutter. The `Icon` widget assumes all icons are square, but many Font Awesome Icons are not.

What about file size and ram usage

This package has been written in a way so that it only uses the minimum amount of resources required.

All links (eg. FontAwesomeIcons.abacus) to unused icons will be removed automatically, which means only required icon definitions are loaded into ram.

Flutter 1.22 added icon tree shaking. This means unused icon "images" will be removed as well. However, this only applies to styles of which at least one icon has been used. Assuming only icons of style "regular" are being used, "regular" will be minified to only include the used icons and "solid" and "brands" will stay in their raw, complete form. This issue is being tracked over in the flutter repository.

However, using the configurator, you can easily exclude styles from the package. For more information, see customizing font awesome flutter

Why aren't the icons showing up on Mobile devices?

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:

  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.

Why aren't the icons showing up on Web?

Most likely, the fonts were not correctly added to the `FontManifest.json`. Note: older versions of Flutter did not properly package non-Material fonts in the `FontManifest.json` during the build step, but that issue has been resolved and this shouldn't be much of a problem these days.

Please ensure you are using Flutter 1.14.6 beta or newer!

Why does mac/linux not run the configurator?

This is most probably due to missing file permissions. Downloaded scripts cannot be executed by default.

Either give the execute permission to util/configurator.sh with $ chmod +x configurator.sh or run the commands by prepending an sh:

$ sh ./configurator.sh

font_awesome_flutter's People

Contributors

albrnick avatar alexandergottlieb avatar andychucs avatar ashotpilosian avatar bartektartanus avatar bcko avatar bensower avatar brianegan avatar britannio avatar chamed avatar daniel-hopkins avatar falkf avatar gslender avatar jinosh05 avatar michaelspiss avatar mortifactor avatar nohli avatar pplante avatar romainfranceschini avatar slightfoot avatar spencerlindemuth avatar stevensnary avatar ulrikkold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

font_awesome_flutter's Issues

Get random icon

Could you provide a way to get random icons?

Thank you :)

icon "fa-user" from Solid font-kit is inaccessible

Icon "fa-user" from Solid font-kit is inaccessible, instead we have the fa-user from regular font-kit.
Would be great if we could select which font style we want the icon. Something like FontAwesomeRegular.user and FontAwesomeSolid.user

Othe think, the icon "fa-mug-hot" is not in files yet.

Thank you in advance for attention!

Size not consistent with material design icons

Fontawesome icons are little bigger than Icons in material/package
Can you make them same size so its consistent across the app
There is a little padding around icons in material package

G+ icon overflows width

Hi :) I'm not sure if this is the right place to report this issue (apologies if not, just close it if so) -- but I'm having an issue with a specific icon - the G+ one, which seems to be wider than what it is reporting ..

So, this Flutter code:

                              children: [
                                new Icon(FontAwesomeIcons.googlePlus),
                                new Text('Logg inn med Google')
                              ]
                          ),

.. will cause the Icon to overlap the text on the right.

See example with the G+ icon in the second FlatButton here: http://i.imgur.com/TXAhJr2.png
Other icons, ie. the Facebook f and Google Plus squared work fine: http://i.imgur.com/HgDmmIj.png

How to get icons to work

I dont see icons in the assets like in font-iconic but I see a builder. There is no example, and I cant get my head around it how to use the builder.

Could you please make some instructions in the readme how to generate icons?

Thank you

Missing icons

Google icons are missing. I used: Icon(FontAwesomeIcons.googlePlus)
and this is the result:
screenshot 2019-01-22 at 10 07 59

Showing Blank Boxes

Description

When Running on Android it is showing blank boxes for the Font Awesome Icons, and Showing the correct ones for Flutter Icons. This was working when I installed it last week. I have also run flutter clean but still no luck.

screenshot_20180507-101256

Flutter Doctor

Rodys-MBP:daily_nasa rodydavis$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.3.1, on Mac OS X 10.13.3 17D102, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 9.3)
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update, run:
        brew uninstall --ignore-dependencies libimobiledevice
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.23.0)
[✓] Connected devices (2 available)

! Doctor found issues in 1 category.

Dependency

font_awesome_flutter: 6.0.0

Use in Project

@override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        backgroundColor: Colors.white,
        title: new Text("Info"),
      ),
      body: new SingleChildScrollView(
        child: new ListBody(
          children: <Widget>[
            new Container(
              height: 10.0,
            ),
            new ListTile(
              leading: new Icon(FontAwesomeIcons.github),
              title: const Text('Github'),
              subtitle: new Text('@AppleEducate'),
              onTap: () {
                globals.Utility
                    .launchURL('https://www.github.com/appleeducate');
              },
            ),
            new Divider(
              height: 20.0,
            ),
            new ListTile(
              leading: new Icon(FontAwesomeIcons.twitter),
              title: const Text('Twitter'),
              subtitle: new Text('@RodyDavis'),
              onTap: () {
                globals.Utility.launchURL('https://www.twitter.com/rodydavis');
              },
            ),
            new Divider(
              height: 20.0,
            ),
            new ListTile(
              leading: new Icon(FontAwesomeIcons.facebook),
              title: const Text('Facebook'),
              subtitle: new Text('@RodyDavis'),
              onTap: () {
                globals.Utility.launchURL('https://www.facebook.com/rodydavis');
              },
            ),
            new Divider(
              height: 20.0,
            ),
            new ListTile(
              leading: new Icon(Icons.apps),
              title: const Text('Apps'),
              subtitle: new Text('by Rody Davis'),
              onTap: () {
                globals.Utility.launchURL('https://www.rodydavis.com/apps');
              },
            ),
            new Divider(
              height: 20.0,
            ),
            new ListTile(
              leading: new Icon(Icons.contact_mail),
              title: const Text('Contact'),
              subtitle: new Text('Submit Issues and Questions'),
              onTap: () {
                globals.Utility.launchURL('https://www.rodydavis.com/about');
              },
            ),
            new Divider(
              height: 20.0,
            ),
            new ListTile(
              leading: new Icon(FontAwesomeIcons.spaceShuttle),
              title: const Text('NASA'),
              subtitle: new Text('All Images provided by API'),
              onTap: () {
                globals.Utility.launchURL('https://api.nasa.gov/');
              },
            ),
            new Divider(
              height: 20.0,
            ),
            new ListTile(
              leading: new Icon(Icons.info),
              title: const Text('Version'),
              subtitle: new Text('$_projectVersion ($_projectCode)'),
              trailing: new Text('$_platformVersion'),
            ),
          ],
        ),
      ),
    );
  }

Would be better if we can use the same image name while rendering in HTML.

Let say we need a addressBook Icon. In flutter we can render via Icon( icon.iconData, size: 100.0, ),

But when we want to use the same icon to render html page we have to use address-book. So, it would be better if you put key as real icons key like address-book by mapping the real name into that object property.

Icon centering

Hey Brian,

I'm loving these icons, but some of them graphically seem shifted relative to their widget constraints - see how the 'users' icon is shifted to the right on this TabBar:

image

Not an issue that rears its head often, but some widget orientations (like the above icon cross-axis centered in a column) look pretty off without adjustment. Is there an easy fix?

Version 0.7.1 is incompatible with Dart SDK

After flutter upgrade I got error with following message as response to flutter packages get:

The current Dart SDK version is 2.1.0-dev.0.0.flutter-be6309690f.
Because app depends on font_awesome_flutter >=4.7.1 which requires SDK version <2.0.0, 
version solving failed.

Building failed.

[SOLVED] font awesome versions >8.0.0 doesn't work on dart 2.4.0 - black box icon only

hey there..
I'm having problem with installing this package, currently I'm using Dart 2.4.0 and when I tried installing font-awesome the version greater than 8.0.0.. didn't work, it shows me a black box only on all icons.

then I tried install other version and I get error when I run flutter packages get
Because MyApp depends on font_awesome_flutter >=4.7.1 <8.0.0 which requires SDK version <2.0.0, version solving failed.

any solutions?

Icons drawing outside of "bounds"

Hey,

I'm using font_awesome_flutter in a project but I'm having an issue I don't know how to work around. In the attached picture you can see that the icon draws outside of the "bounds" that I'm trying to layout. This is making it super difficult to center an icon in a circle, like I'm trying to in my app :)

Is this something happening in the package or is there a way to lay it out better in flutter?

Thanks for any help :)

image

Handle same icon name with different style available

Hello,

Is there any way to have the same icon but with a different style ?
For example, font awesome icon heart is both present in Regular and Solid style. By default it is set to :

static const IconData heart = const IconDataRegular(0xf004);

But how can we handle :

static const IconData heart = const IconDataSolid(0xf004);

Have we to create a new const and add a new name like heart_solid ?

wikipediaW not aligned properly

wikipediaW icon is not aligned in the center.

Work around to make it center:

Align(
            alignment: Alignment.centerLeft,
            child: Icon(FontAwesomeIcons.wikipediaW),
  )

How to use Regular and Brand icon formats?

Hello!
Sorry if this sounds "dumd" but the documentation says that the library contains Regular, Solid and Brand formats, but I can't figure out a way of how to use them.

Is this implemented? If yes, maybe a improved documentation could be very handy!

Thanks!

Installation Doesn't Work with Android SDK v#>2

Peters-MacBook-Pro:flutter patientplatypus$ flutter packages upgrade
The current Dart SDK version is 2.3.0-dev.0.5.flutter-a1668566e5.       
                                                                        
Because yaddayaddayadda depends on font_awesome_flutter >=4.7.1 <8.0.0 which requires SDK version <2.0.0, version solving failed.
Running "flutter packages upgrade" in flutter...                        
pub upgrade failed (1)

Target URI doesn't exit.

import 'package:font_awesome_flutter/font_awesome_flutter.dart';

Target URI doesn't exit.

I added dependencies like this:

dependencies:
  flutter:
    sdk: flutter
    font_awesome_flutter: 8.4.0

See pictures of the icons

It is really handy to have pictures next to icons like flutter Icons. Any chance this might be implemented here, or idea how to do it so I can do it?

Fontawesome Spinner icon is not spinning

I have used spinner icon as below but some how it is not spinning. It is just stuck with load icon.

       Align(
               alignment: Alignment.centerRight,
               child: IconButton(
                 icon: Icon(
                   FontAwesomeIcons.spinner,
                   color: Colors.white,
                   size: [18.0,]
                 ),
                 onPressed: () {}
               ),
             ),

screen shot 2018-09-03 at 2 37 09 pm

Dependencies Error

Because myapp depends on font_awesome_flutter >=4.7.1 <8.0.0 which requires SDK version <2.0.0, version solving failed.

Icon Box and padding don't resize

Screenshot 2020-01-30 at 23 13 07

this is what happens, the visible part of the icon gets bigger, but the box that is registered by the layout etc. doesn't resize so the whole layout doesn't work out. I ran flutter clean, restarted all the devices, deleted the app from simulator, tried on android, tried other icons (some don't misalign to the side, but same problem with the icon box).

Column(
                      children: <Widget>[
                        IconButton(
                          icon: Icon(
                            FontAwesomeIcons.mars,
                            size: 80,
                            color: Colors.white,
                          ),
                        ),
                        SizedBox(height: 15),
                        Text(
                          'MALE',
                          style: TextStyle(
                            fontSize: 18.0,
                            color: Color(0xFF8D8E98),
                          ),
                        )
                      ],
                    ),

Flutter Doc:
`Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.2 19C57, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] Connected device (1 available)

• No issues found!

There was a new Flutter version available earlier when I ran flutter doctor, but the same result before and after.

I found a solution here, but it gets pretty hardcoded this way and wrapping the container in an expanded widget did nothing for me.

I apologise if this issue is messy or unnecessary, just let me know and I'l close it. I'm pretty new to this whole thing.

Get icon by original name

Nice work :)
Would be nice if there were a function to get Icons by there original name like:
FontAwesomeIcons.getByOriginalName('paint-brush');

if name dose not exists return the "?" :)

Add `fromString` method

Add fromString method that will allow creating icons from strings. Eg:

FontAwesome.fromString("addressCard") should return const IconDataRegular(0xf2bb)

You can do this by generating another file with Map<String, IconData>

Integrating font awesome pro

How can I add font-awesome pro features with this plugin?
Is there any way to integrate font awesome pro licence key with font-awesome-flutter so that all pro fonts are also available for use?

Rectangular icons are centered incorrectly

image

Code sample:

new CircleAvatar(child: new Icon(FontAwesomeIcons.users,size: 70.0, color: Colors.white,),
        backgroundColor: Colors.orange, radius: 70.0,);

Next example (this time from your documentation). IconButton repeated three times in Row. As you can see one icon overlaps another.
image

var button = new IconButton(
    iconSize: 100.0,
    icon: new Center(child:new Icon(FontAwesomeIcons.gamepad,)),
    alignment: Alignment.bottomRight,
    onPressed: () { print("Pressed"); }
);
Row(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[button, button, button],)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.