4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

How to use custom icons inĀ Flutter

It's easy, thanks to the creators of FlutterIcon and FontellošŸ’–

Read the Medium article here

How itĀ works

The custom icons will be converted into a ttf font file, which will be added into the project. An automatically generated Dart file will be added, allowing icons to be used like Icon(CustomCons.upvote).

  1. Go to FlutterIcon.com
  2. Click on the icons that you want, upload custom SVG files, font-files, or JSON files
  3. Insert your own name like 'Custom', 'Icecons' etc.
  4. Click 'Download' and extract files
  5. The config.json is absolute genius, it saves all your selections and custom icons, so when you revisit the website just drag and drop it in and it's all there again.
  6. Move the ttf file into your desired directory (e.g. fonts/CustomIcons.ttf)
  7. Move the dart file into your desired directory in lib (I did lib/presentation/custom_icons_icons.dart )
  8. Follow the instructions at the top of your dart file and copy the fonts code into pubspec.yml (I put mine underneath flutter: uses-material-design)
    flutter run to ensure project compiles and app starts expectedly
  9. Use your icon!
  10. Party šŸŽ‰

Tabs Example:

import CustomIcons from '../lib/presentation/custom_icons_icons.dart'
Tab(icon: Icon(CustomIcons.heart)

Here I've imported my dart class as CustomIcons and used the heart in a tab. In IntelliJ, you can write the code first, then Alt-Enter on CustomIcons and it will add the correct relative path for the import for you.

For more information like, how to create your own icons using Illustrator, import/export fonts visit the full wiki: https://github.com/ilikerobots/polyicon/wiki/Help

Coding is not just about features, it's also about Collaboration.

Happy Coding!

4 upvotes $0.00

Replies (4)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: