• Stars
    star
    835
  • Rank 54,605 (Top 2 %)
  • Language
    Dart
  • License
    Other
  • Created over 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Font Awesome Icon pack available as Flutter Icons

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.2.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

More Repositories

1

flutter_launcher_icons

Flutter Launcher Icons - A package which simplifies the task of updating your Flutter app's launcher icon. Fully flexible, allowing you to choose what platform you wish to update the launcher icon for and if you want, the option to keep your old launcher icon in case you want to revert back sometime in the future. Maintainer: @MarkOSullivan94
Dart
1,986
star
2

chewie

The video player for Flutter with a heart of gold
Dart
1,940
star
3

community

Flutter Community - A central place for community made Flutter content.
1,558
star
4

plus_plugins

Flutter Community Plus Plugins
Dart
1,554
star
5

flutter_webview_plugin

Community WebView Plugin - Allows Flutter to communicate with a native WebView.
Java
1,480
star
6

get_it

Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
Dart
1,323
star
7

flutter_sticky_headers

Flutter Sticky Headers - Lets you place "sticky headers" into any scrollable content in your Flutter app. No special wrappers or magic required. Maintainer: @slightfoot
Dart
1,075
star
8

flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
Kotlin
913
star
9

flutter_workmanager

A Flutter plugin which allows you to execute code in the background on Android and iOS.
Dart
841
star
10

flutter_blurhash

Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido
Dart
523
star
11

redux.dart

Redux for Dart
Dart
515
star
12

flutter_after_layout

Flutter After Layout - Brings functionality to execute code after the first layout of a widget has been performed, i.e. after the first frame has been displayed. Maintainer: @slightfoot
Dart
476
star
13

flutter-draggable-scrollbar

Draggable Scrollbar - A scrollbar that can be dragged for quickly navigation through a vertical list. Additional option is showing label next to scrollthumb with information about current item. Maintainer: @marica27
Dart
442
star
14

responsive_scaffold

Responsive Scaffold - On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item. Maintainer: @rodydavis
Dart
362
star
15

app_review

App Review - Request and Write Reviews and Open Store Listing for Android and iOS in Flutter. Maintainer: @rodydavis
Dart
333
star
16

backdrop

Backdrop implementation in flutter.
Dart
328
star
17

flutter_infinite_listview

Flutter Infinite ListView - ListView with items that can be scrolled infinitely in both directions. Maintainer: @slightfoot
Dart
306
star
18

flutter_google_places

Google Places - Google places autocomplete widgets for flutter. No wrapper, use https://pub.dev/packages/google_maps_webservice. Maintainer: @juliansteenbakker
Dart
303
star
19

flutter_sms

A Flutter plugin to Send SMS and MMS on iOS and Android. If iMessage is enabled it will send as iMessage on iOS. This plugin must be tested on a real device on iOS. Maintainer: @rodydavis
Dart
245
star
20

flutter_uploader

background upload plugin for flutter
Dart
211
star
21

page_turn

Page Turn Widget - Add a page turn effect to widgets in your app. Maintainer: @rodydavis
Dart
194
star
22

import_sorter

🎯 Automatically organize your dart imports. Maintainer: @gleich
Dart
169
star
23

flutter_contacts

Contacts Service - A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
Java
153
star
24

flutter_wear_plugin

A plugin that offers widgets for Wear OS by Google
Dart
135
star
25

rx_command

RxCommand - Reactive event handler wrapper class inspired by ReactiveUI. Maintainer @escamoteur
Dart
134
star
26

breakpoint

Breakpoint - A Flutter plugin to calculate the material design breakpoints. Maintainer: @rodydavis
Dart
109
star
27

get_version

Get Version - Get the Version Name, Version Code, Platform and OS Version, and App ID on iOS and Android. Maintainer: @rodydavis
Ruby
95
star
28

native_widgets

Native Widgets - A new Flutter package for using Android and iOS natively on each platform. Maintainer: @rodydavis
Dart
92
star
29

state_persistence

State Persistence - Persist state across app launches. By default this library store state as a local JSON file called `data.json` in the applications data directory. Maintainer: @slightfoot
Dart
74
star
30

persist_theme

Persist Theme - A flutter plugin for persisting the theme data. Support for Dark Modes. Maintainer @rodydavis
Dart
69
star
31

wakelock_plus

Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
Dart
68
star
32

dart_sealed_unions

Sealed Unions for Dart. Maintainer: @nodinosaur
Dart
66
star
33

flutter-styleguide

Flutter Style Guide. Suggested styles and best practices for teams using Flutter.
49
star
34

firestore_helpers

Firestore Helpers - Firestore helper function to create dynamic and location based queries. Maintainer: @escamoteur
Dart
48
star
35

rocket_guide

An example project for #30DaysOfFlutter.
Dart
34
star
36

android_id

Maintainer: @nohli
Dart
33
star
37

admin_dashboard

Admin Dashboard - a Flutter Community Dashboard that assists admins by rounding up and providing the admins with information regarding issues, latest activities on repositories, maintainers, level of access and a trigger to build and deploy to pub. dev, and more. (Work In Progress)
Dart
24
star
38

arcgis_map_sdk

Flutter implementation of the ArcGis map framework by esri
Dart
12
star
39

interval_tree

A non-overlapping interval tree for Dart
Dart
5
star
40

redux_undo

Redux Undo - Make your redux store undo- and redoable. Inspired by the JS redux_undo package. Maintainer: @michelengelen
Dart
5
star
41

transfer-guide

The official Flutter Community Transfer Guide for package maintainers wanting to transfer their package to the organization.
5
star
42

site

Website
Dart
4
star
43

readme_generator

A Dart program that generates the README.md for the FlutterCommunity/community repo.
Dart
3
star
44

fluttercommunity.github.io

The Flutter Community website.
HTML
1
star