패키지, 저장소 및 앱 카테고리 검색

패키지 상세v11.0.0

font_awesome_flutter

Flutter 아이콘으로 제공되는 Font Awesome 아이콘 팩입니다. 앱에서 사용할 수 있는 추가로 2000개의 아이콘을 제공합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
115만
좋아요
5천
Pub 점수
160

패키지 설치

flutter pub add font_awesome_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Font Awesome Flutter는 2000개 이상의 아이콘을 포함한 방대한 Font Awesome 아이콘 라이브러리를 Flutter 애플리케이션에 가져오는 패키지입니다. Android, iOS, Web, macOS, Windows, Linux 플랫폼에서 확장 가능하고 사용자 정의 가능한 벡터 아이콘을 쉽게 통합할 수 있게 해줍니다. 위젯에서 아이콘을 사용하기 위한 간단하고 일관된 API를 제공하여 최소한의 설정으로 UI 디자인을 향상시킵니다. 시각적 피드백이 풍부하거나 아이콘을 통해 직관적인 탐색이 필요한 앱에 적합합니다.

사용 사례

  • UI 요소에 확장 가능한 아이콘 추가
  • 시각적 신호를 통한 앱 탐색 개선
  • 다양한 플랫폼 간에 일관된 아이콘 그래피 만들기
  • 아이콘 기반 메트릭을 사용한 대시보드 설계
  • 국제 아이콘 기준을 활용한 사용자 인터페이스 구축

주요 기능

  • Font Awesome에서 2,000개 이상의 아이콘
  • 크로스 플랫폼 지원
  • Flutter 위젯과의 간편한 통합
  • 확장 가능한 벡터 그래픽
  • 사용자 지정 가능한 색상 및 크기
  • 경량이고 성능이 뛰어남

적합한 대상

  • 모바일 및 웹 앱 개발자
  • Flutter를 사용하는 UI/UX 디자이너
  • 표준화된 아이콘 세트가 필요한 프로젝트
  • 대규모 아이콘 라이브러리를 찾는 개발자
  • 일관된 시각적 디자인을 추구하는 앱

고려 사항

  • 초기 설정을 위해 인터넷이 필요합니다. pub.dev를 통해
  • 아이콘 수로 인한 큰 번들 크기
  • 앱 크기를 줄이기 위해 선택적 아이콘 가져오기가 필요할 수 있습니다
  • 모든 Font Awesome 스타일이 기본적으로 포함되지는 않습니다
  • 다른 패키지와의 아이콘 이름 충돌 가능성

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Favorite

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

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

:exclamation: 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 desktop version of font awesome pro and open it
  • Move all .otf files from the otfs directory and icons.json from metadata to path/to/your/font_awesome_flutter/lib/fonts. Replace existing files.
    • To prevent issues with the web and testing, make sure to replace spaces in the filenames with dashes.
    • Newer versions might have an icon-families.json. If this is the case, move its contents to path/to/your/font_awesome_flutter/lib/fonts/icons.json.
  • 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 configurator tool, this is now an optional feature. Run the tool with the --dynamic flag to generate...

$ ./configurator.sh --dynamic

...and use the following import to access 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

순위