An IconPicker for Flutter

Overview

FlutterIconPicker

ci Version Generic badge

This package provides an IconPicker with supported (or custom provided) Icons which can be picked through an AlertDialog. All Icons are mapped with its names in the IconData. This is necessary to make it possible to search through the icons. Fulltextsearch including a note if no results where found.

IconPicker

Supported IconPacks

IconPack Supported
Material
(includes Sharp, Rounded and Outlined)
Cupertino
FontAwesome
LineAwesome

Usage

To use this package, add flutter_iconpicker as a dependency in your pubspec.yaml file.

API-Reference

Parameter Type Default Short description
context (only required) BuildContext - Required due to AlertDialog's base.
adaptiveDialog bool false If true, IconPicker will adapt depending on the screen size. If false, IconPicker will show itself inside an AlertDialog.
barrierDismissible bool true Defines if the user can dismiss the dialog by tapping on the outside barrier.
iconSize double 40.0 Defines the size for the all icons, that can be picked.
iconColor Color Theme.of(context).iconTheme.color Set the color for the all icons, that can be picked.
mainAxisSpacing double 5.0 How much space to place between children in a run in the main axis.
crossAxisSpacing double 5.0 How much space to place between children in a run in the cross axis.
iconPickerShape ShapeBorder RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)) The dialogs shape for the picker.
backgroundColor Color Theme.of(context).dialogBackgroundColor The color for the AlertDialog's background color.
constraints BoxConstraints If adaptiveDialog == true then it's default is: BoxConstraints(maxHeight: 500, minWidth: 450, maxWidth: 720), otherwise: BoxConstraints(maxHeight: 350, minWidth: 450, maxWidth: 678). The dialogs BoxConstraints for limiting/setting: maxHeight, maxWidth, minHeight and minWidth.
title Widget Text('Pick an icon') The title for the Picker. Sits above the [SearchBar] and [Icons].
closeChild Widget Text('Close',textScaleFactor: 1.25,) The content for the AlertDialog's action FlatButton which closes the default dialog.
searchIcon Icon Icon(Icons.search) Sets the prefix icon in the [SearchBar]
searchHintText String 'Search' Sets the hintText in the TextField of [SearchBar]
searchClearIcon Icon Icon(Icons.close) Sets the suffix icon in the [SearchBar]
noResultsText String 'No results for:' The text to show when no results where found for the search term.
showTooltips bool false Shows the labels underneeth the proper icon.
showSearchBar bool true Shows the search bar above the icons if true
iconPackModes List<IconPack> const <IconPack>[IconPack.material] The modes which Icons to show.
customIconPack Map<String, IconData> null The customized icons that can be used instead.

IconPackMode

You can select the wished IconPacks through the argument: iconPackModes. This defaults to const <IconPack>[IconPack.material]. For further usage have a look in the example.

You own Icons

If you don't want to use the default IconPacks, you can also provide your own IconPack by creating a Map<String, IconData> with the names of your icons and the specific IconData. Just pass it to customIconPack and set the iconPackMode: IconPack.custom.

Result of IconPicker and further usage (saving and retreiving)

The picker is returning (as shown in the example method _pickIcon() underneeth) an IconData which is nothing else then this class for example:

  IconData(0xe3af, fontFamily: 'MaterialIcons');    // Icons.camera

that's representing an Material icon.

So if you plan to save the picked icon anywhere (sqflite, firebase, etc.), you can use the serialization methods:

  1. Call this to convert the picked IconData to a Map:

IconData to Map

  serializeIcon(iconData)
  1. You can retreive the IconData by passing the mapped IconData:

Map to IconData

  deserializeIcon(map)

Example

If you're looking for a complete example with DB storage, jump in here: ExampleProject

import 'package:flutter/material.dart';
import 'package:flutter_iconpicker/flutter_iconpicker.dart';

void main() {
  runApp(MaterialApp(
    home: HomeScreen()
  ));
}

class HomeScreen extends StatefulWidget {
  HomeScreen({Key key}) : super(key: key);

  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  Icon _icon;

_pickIcon() async {
  IconData icon = await FlutterIconPicker.showIconPicker(context, iconPackModes: [IconPack.cupertino]);

  _icon = Icon(icon);
  setState((){});

  debugPrint('Picked Icon:  $icon');
}

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            onPressed: _pickIcon,
            child: Text('Open IconPicker'),
          ),
          SizedBox(height: 10),
          AnimatedSwitcher(
            duration: Duration(milliseconds: 300),
            child: _icon != null ? _icon : Container()
          )
        ])
      ),
    );
  }
}
Comments
  • Update icons

    Update icons

    After upgrading to Flutter 2.10.2, there is a new error regards to an icon being removed.

        ../../.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.2/lib/IconPicker/Packs/Material.dart:4894:31: Error: Member not found: 'pie_chart_outlined'.
          'pie_chart_outlined': Icons.pie_chart_outlined,
                                      ^^^^^^^^^^^^^^^^^^
    
    opened by CripyIce 15
  • Build fails in Flutter 3.0

    Build fails in Flutter 3.0

    It was working fine. Today I just updated my flutter to Flutter 3.0. Now, when Iflutter run this error shows and build fails.

    
    /C:/Users/ameen/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.4+1/lib/IconPicker/Packs/Material.dart(1230,25): error G75B77105: Member not found: 'class__sharp'. [C:\posterapp\build\windows\flutter\flutter_assemble.vcxproj]
    /C:/Users/ameen/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.4+1/lib/IconPicker/Packs/Material.dart(1231,27): error G75B77105: Member not found: 'class__rounded'. [C:\posterapp\build\windows\flutter\flutter_assemble.vcxproj]
    /C:/Users/ameen/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.4+1/lib/IconPicker/Packs/Material.dart(1232,28): error G75B77105: Member not found: 'class__outlined'. [C:\posterapp\build\windows\flutter\flutter_assemble.vcxproj]
    
    /C:/Users/ameen/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.4+1/lib/IconPicker/iconPicker.dart(47,20): warning G1E0FE241: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null. [C:\posterapp\build\windows\flutter\flutter_assemble.vcxproj]
    
    opened by ameenvga 12
  • Opening really slow

    Opening really slow

    When i click Open IconPicker it takes about 3 seconds before it opens. is it possible to remove some icons to make it open faster? i don't need all the icons. is it also possible to add icons myself as the developer?

    opened by frederikw03 12
  • Missing icons six_ft_apart

    Missing icons six_ft_apart

    In flutter 2.6.0-0.0.pre six_ft_apart icons are not available. I tried to commit a commit to this repository but I don't have enough permission to do so so I forked to solve this problem: https://github.com/apps-auth/FlutterIconPicker/commit/4acd274dc28dac3591ec9ca6a3b6458d378da6ab

    opened by apps-auth 10
  • A problem with storing icon

    A problem with storing icon

    Hello,

    I wanted to use icons as a symbol of a category. I need to store the selected icon in a database. The simplest way is store fields: codePoint, fontFamily, fontPackageand matchTextDirection. This solution is suggested in README file and in a few Stackoverflow posts but this doesn't work. After some time the icons are different.

    In REDME there is an example: IconData(0xe3af, fontFamily: 'MaterialIcons'); // Icons.camera

    but now under 0xe3af is: static const IconData record_voice_over_outlined = IconData(0xe3af, fontFamily: 'MaterialIcons');

    This causes changing icons after some time. In the database, I store the above four fields. This means we cannot trust values for a long time. Using the code Icons.camera is ok and works for all time.

    I think we need to store icons in a different way.

    I think something like that:

      Map<String, String> iconToMap(IconPack iconPack, IconData icon) {
        if (iconPack == IconPack.material) {
          final iconEntry =
              icons.entries.firstWhere((iconEntry) => iconEntry.value == icon); // icons from src/material.icons.dart
          return {
            'pack': "material",
            'key': iconEntry.key,
          };
        }
        // etc.
      }
    
    opened by merskip 10
  • Android release build failing due to some tree shake icon issue

    Android release build failing due to some tree shake icon issue

    Thanks for this awesome library. I am using latest version of this library, But somehow I can't able to create release apk.

    Please find logs here:

    You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
    If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to
    reduce the APK size.
        To generate an app bundle, run:
            flutter build appbundle --target-platform android-arm,android-arm64,android-x64
            Learn more on: https://developer.android.com/guide/app-bundle
        To split the APKs per ABI, run:
            flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
            Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
    This application cannot tree shake icons fonts. It has non-constant instances of IconData at the following locations:
      - file:///Users/bipinvaylu/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-2.1.2/lib/Serialization/iconDataSerialization.dart:22:14
    Running Gradle task 'assembleRelease'...                                
                                                                    
    FAILURE: Build failed with an exception.                                                                                                                                                                              
    * Where:                                                                                                   
    Script '/Users/bipinvaylu/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 897                                                                                                                             
    * What went wrong:                                                                                         
    Execution failed for task ':app:compileFlutterBuildRelease'.                                               
    > Process 'command '/Users/bipinvaylu/flutter/bin/flutter'' finished with non-zero exit value 1     
    
    * Try:                                                                                                     
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
    Run with --scan to get full insights.
                                                                                                               
    * Get more help at https://help.gradle.org                                                                                                                                                                            
    BUILD FAILED in 2m 46s                                                                                     
    Running Gradle task 'assembleRelease'...                                                                   
    Running Gradle task 'assembleRelease'... Done                     167.1s (!)
    Gradle task assembleRelease failed with exit code 1
    
    

    Please let me know if you want any other details.

    opened by bipinvaylu 8
  • [How To] Create Map<String, IconData> from a custom IconData class?

    [How To] Create Map from a custom IconData class?

    Hello, I want to use this LineIcons as a custom icon font in flutter icon picker. The showIconPicker method accepts a Map<String, IconData> customIconPack argument, However, I want to use this LineIcons class as it is. Manually converting all of the values from this LineIcons class into a map will be a tedious process! Is there any way to convert this LineIcons class into the required map on the fly? Or any alternative to use this class with icon picker?

    opened by pranjal-joshi 7
  • FlutterIconPicker not updating to current params

    FlutterIconPicker not updating to current params

    Hello,

    I am facing an issue where on one screen I pass my own customIconPack and after pushing a new screen with iconPackModes: [IconPack.fontAwesomeIcons] and going back to the previous I get shown all the icons and not just my custom one. I believe this is due to the fact that the showIconPicker is static.

    Congrats on the lib btw.

    opened by veloso14 6
  • Adobe icon not available in FontAwesome 5.15, fails compile

    Adobe icon not available in FontAwesome 5.15, fails compile

    https://github.com/fluttercommunity/font_awesome_flutter/pull/124

    This PR removed the Adobe icon, which now fails my build, even though I am not using that icon.

    I suggest fixing the version of font_awesome_flutter to 8.8.1 until you add all the new icons and remove the old ones.

    Error:

    ../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-2.1.5/lib/IconPicker/Packs/FontAwesome.dart:16:29: Error: Getter not found: 'adobe'.
      'adobe': FontAwesomeIcons.adobe,
                                ^^^^^
    
    opened by nstrelow 6
  • Cant change icon after setting a default icon in code

    Cant change icon after setting a default icon in code

    i have in my code saved what icon the user chooses earlier and set is as a default as seen here: 109729005_687493292098503_8436158623486473125_n

    My code to auto fill the spot: ` Widget build(BuildContext context) {

    icon = mapToIconData(new Map<String, dynamic>.from(widget.document['icon']));
    _icon = Icon(icon);
    

    ` when i then try to choose a new icon it executes but its not chosen? it just keeps the icon i choose 'in code'

    this is the code to open the picker ` _pickIcon() async {

    icon = await FlutterIconPicker.showIconPicker(context, iconPackMode: IconPack.fontAwesomeIcons); _icon = Icon(icon); setState((){}); debugPrint('Picked Icon: $icon'); } `

    Have i done something wrong? What can i do to fix this

    help wanted question 
    opened by frederikw03 6
  • Fixed

    Fixed "Error: Getter not found: 'adobe'"

    Hello,

    I have Flutter in version 1.22.0 and flutter_iconpicker in 2.1.5. While I want to build my project I get an error:

    Launching lib\main.dart on Android SDK built for x86 64 in debug mode...
    Running Gradle task 'assembleDebug'...
    /D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-2.1.5/lib/IconPicker/Packs/FontAwesome.dart:16:29: Error: Getter not found: 'adobe'.
      'adobe': FontAwesomeIcons.adobe,
                                ^^^^^
    
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904
    
    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'D:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 11s
    Exception: Gradle task assembleDebug failed with exit code 1
    

    It seems as adobe icon was removed in some version.

    opened by merskip 5
  • This application cannot tree shake icons fonts.

    This application cannot tree shake icons fonts.

    I'm tyring to build to production and am getting the following error:

    This application cannot tree shake icons fonts. It has non-constant instances of IconData at the following locations:

    • file:///Users/mac/Development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-3.2.2/lib/Serialization/iconDataSerialization.dart:76:16

    FAILURE: Build failed with an exception.

    • Where: Script '/Users/mac/Development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1159

    • What went wrong: Execution failed for task ':app:compileFlutterBuildProdRelease'.

    Process 'command '/Users/mac/Development/flutter/bin/flutter'' finished with non-zero exit value 1

    • Try:

    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    • Get more help at https://help.gradle.org
    opened by nagringapp 0
  • Issues with Deserialization After Upgrading

    Issues with Deserialization After Upgrading

    First of all, thank you so much for making this package. It's a very important part of my app.

    I started using this package in 2020 and am on version 2.2.3. I am trying to upgrade dependencies, but it breaks at version 3.0.0 because of serialization. Right now, the data is stored like this in Firebase

    {
      "codePoint": 59453,
      "fontFamily": "MaterialIcons",
      "fontPackage": null,
      "matchTextDirection": false
    }
    

    When I deserialize that now with the default version, I receive null because of this line: https://github.com/Ahmadre/FlutterIconPicker/blob/master/lib/Serialization/iconDataSerialization.dart#L83. How do I get my data working with the new versions so I can upgrade this package? I have several thousand monthly users that will all lose their selected icons otherwise :(

    opened by TheRedPanda17 11
  • Way to Exclude Packs

    Way to Exclude Packs

    Great Package.

    I noticed that when building for web this package incresed the size of of my overall output by nearly 1 MByte. Is there an easy way (other than forking) to exclude the standard packs? I only need my own custom icons.

    Thanks,

    Don

    opened by dedvalson 1
Owner
Rebar Ahmad
Software-Engineer | - Flutter - Firebase - Ionic/Angular - GraphQL - MongoDB - Node/Express - Java Spring Boot - Docker / Kubernetes / HELM
Rebar Ahmad
ABC of Flutter widgets. Intended for super beginners at Flutter. Play with 35+ examples in DartPad directly and get familiar with various basic widgets in Flutter

Basic Widgets Examples This is aimed for complete beginners in Flutter, to get them acquainted with the various basic widgets in Flutter. Run this pro

Pooja Bhaumik 815 Jan 3, 2023
Minha primeira aplicação android utilizando Flutter feito no curso de Flutter da Cod3r Cursos Online. O foco dessa aplicação foi um contato inicial com o Flutter.

expenses Expenses é uma aplicação android simples feita em Flutter para controlar despesas pessoais. A aplicação consiste em: Listar transações feitas

Guilherme Teixeira Ais 2 Apr 19, 2022
Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API.

Flutter Github Following Application Watch it on Youtube Previous Designs Checkout my Youtube channel Installation Please remember, after cloning this

Mohammad Rahmani 110 Dec 23, 2022
Flutter RSS feed parsing - A demo application of flutter which parse RSS XML contents to the flutter application

Flutter RSS feed parsing demo This is demo application of flutter which shows ho

Nyakuri Levite 3 Nov 15, 2022
Boris Gautier 1 Jan 31, 2022
Code for Flutter Talk from Flutter Vikings 2022: Custom User Interactions in Flutter

Custom User Interactions - Flutter Vikings 2022 A companion app for the Flutter Vikings 2022 talk - Custom User Interactions with Shortcuts, Intents,

Justin McCandless 9 Sep 16, 2022
Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI 1/2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Fl

Johannes Milke 46 Dec 6, 2022
Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI #2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flu

Johannes Milke 45 Dec 15, 2022
Let's create a selectable Flutter Navigation Drawer with routing that highlights the current item within the Flutter Sidebar Menu.

Flutter Tutorial - Sidebar Menu & Selectable Navigation Drawer Let's create a selectable Flutter Navigation Drawer with routing that highlights the cu

Johannes Milke 12 Dec 26, 2022
Components that optimize Flutter fluency.(Flutter 流畅度优化的通用方案,轻松解决卡顿问题)

Flutter fluency optimization component "Keframe" Page switching fluency improved: How to use Project depend on: Quick learning Constructor Description

Ke Technologies 793 Dec 30, 2022
Challenge yourself every weekend with flutter. Join me to implement challenging UI & digital designs using Flutter.

Weekend With Flutter This is my new challenge. Every weekend, I want to implement challenging UI & digital designs using Flutter. you can join me with

Payam Zahedi 16 Feb 24, 2022
Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's information in Flutter.

Flutter Tutorial - User Profile & SharedPreferences Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's inf

Johannes Milke 21 Dec 3, 2022
Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navigation Drawer in Flutter.

Flutter Tutorial - Collapsible Sidebar Menu & Navigation Drawer Let's create a Flutter Collapsible Sidebar Menu that can collapse and expand the Navig

Johannes Milke 22 Jan 3, 2023
🚗 Apple CarPlay for Flutter Apps. Aims to make it safe to use apps made with Flutter in the car by integrating with CarPlay.

CarPlay with Flutter ?? Flutter Apps now on Apple CarPlay! flutter_carplay aims to make it safe to use iPhone apps made with Flutter in the car by int

Oğuzhan Atalay 156 Dec 26, 2022
Flutter ui boilerplate is easiest way to create new flutter project with clean code and well organized file folder.

Flutter UI Boilerplate "Sharing for fun" Flutter ui boilerplate is easiest way to create new flutter project with clean code and well organized file f

Dimas Ibnu Malik 122 Dec 1, 2022
This is a Flutter app which shows how to use the PageView Class in your Flutter App

page_view_class A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Shehzaan Mansuri 1 Oct 25, 2021
Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to developing Flutter apps.

Flutter Architecture Blueprints Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to dev

Katsuyuki Mori 2 Apr 9, 2022
Flutter Viral News App using : Flutter + Rest Api + Bloc / Cubit

Intro Viral News App on Flutter. The tech used: Flutter widgets + Flutter Bloc / Cubit + Rest Api Check the screenshot : P.S Make sure to upgrade your

Ihab Zaidi 8 Nov 2, 2022