Code Monkey home page Code Monkey logo

fluttericonpicker's Introduction

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

Disclaimer (Important)

This package is maintained regularly, is stable and is used in production by many software solutions out there (Thank you all at this point ๐Ÿ™).

However, it is not guaranteed that all icons are displayed correctly -> why? -> flutter framework is constantly changing codePoint's for example for Icons.camera. So if you develop an app which uses an older flutter version and flutter_iconpicker version, you're good to go, but if you want to update your app and flutter version, the codePoint's could be broken and not matching to Icons.camera for example anymore!

So what can we do?:

Simply use custom icons by providing a list of IconData's to the IconPicker (with the correct codePoint's and NOT Icons.camera!)

Good: 'camera': IconData(0xe3af, fontFamily: 'MaterialIcons')

Bad: 'camera': Icons.camera

For example if you want to provide material icons, copy the actual icons from here: icons.dart and provide them to the IconPicker as custom icons.

Supported IconPacks

IconPack Supported
Material โœ…
Material Sharp โœ…
Material Rounded โœ…
Material Outlined โœ…
Cupertino โœ…
FontAwesome โœ…
LineAwesome โœ…

Usage

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

Before Getting Started (Important)

IconPacks are very large in size and are generated on demand by you as the developer to always keep your app size as small as possible!

To generate the IconPacks you need, just execute following command:

dart run flutter_iconpicker:generate_packs --packs <material,cupertino,..>

Replace <material,cupertino,..> with the IconPack names you want! E.g. --packs material,cupertino (comma separated!)

For the complete list of available pack names see: Available IconPacks (only those with path!)

For more see:

dart run flutter_iconpicker:generate_packs --help

This dart cli program generates all IconPacks you need.

If you tend to change your IconPacks, you always have to re-run that command!

To make it easier you can setup this command easily as a pre-script running before launching your flutter app (For info on this if you use VSCode have a look at: https://code.visualstudio.com/docs/editor/tasks). This automates your development workcycle and for building release apps, just run that dart script before building.

Building

If you build your app it may fail because of this package. #TreeShakeIcons

To be able to build your app, add to your build command the flag: --no-tree-shake-icons and you should be good to go!

For more see: flutter/flutter#16311

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]
searchComparator SearchComparator (String searchValue, IconPickerIcon icon) => icon.name.toLowerCase().contains(searchValue.toLowerCase()) The [searchComparator] can be used to define a custom search function which should return a [bool]
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)

Migration-Guide when updating to >= 3.3.1 (BREAKING CHANGE)

The IconPicker is now called via IconData? icon = await showIconPicker(... and not anymore like: IconData? icon = await FlutterIconPicker.showIconPicker(.... Please update your code accordingly!

Material icons are now separated into:

  • Default -> only normal icons (without Sharp, Rounded, Outlined)
  • All -> All Material Icons (including Sharp, Rounded, Outlined)
  • Sharp -> Only Sharp Material Icons
  • Rounded -> Only Rounded Material Icons
  • Outlined -> Only Outlined Material Icons

โš  Use IconPack.allMaterial instead, if you still want to display all Material Icons. The old enum value was: IconPack.material โš 

If you work with Material Icons please always pass the corresponding IconPack via the optional parameter when serializing:

serializeIcon(_iconData, iconPack: IconPack.allMaterial);
    
...
    
deserializeIcon(
  Map<String, dynamic>.from(await box.get('iconData')),
  iconPack: IconPack.allMaterial,
);

If you display directly using serializeIcon function, als consider it:

Text(
  'Database Entry:\n${serializeIcon(_iconData, iconPack: IconPack.allMaterial).toString()}',
),

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(
    const MaterialApp(
      home: HomeScreen(),
    ),
  );
}

class HomeScreen extends StatefulWidget {
  const 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>[
            ElevatedButton(
              onPressed: _pickIcon,
              child: const Text('Open IconPicker'),
            ),
            const SizedBox(height: 10),
            AnimatedSwitcher(
              duration: const Duration(milliseconds: 300),
              child: _icon ?? Container(),
            ),
          ],
        ),
      ),
    );
  }
}

Troubleshooting

Problem:

This application cannot tree shake icons fonts. It has non-constant instances of IconData at the following locations:
  - file:///C:/Users/You/Development/FlutterIconPicker/lib/Serialization/iconDataSerialization.dart:127:16
Target web_release_bundle failed: Exception: Avoid non-constant invocations of IconData or try to build again with --no-tree-shake-icons.

Solution:

Add to your build command: --no-tree-shake-icons.

--

Problem:

My selected IconPacks are not displayed when I set the iconPackModes: [...]!

Solution:

IconPacks are very large in size and are generated on demand by you as the developer to always keep your app size as small as possible!

To generate the IconPacks you need, just execute following command:

dart run flutter_iconpicker:generate_packs --packs <material,cupertino,..>

Replace <material,cupertino,..> with the IconPack names you want! E.g. --packs material,cupertino (comma separated!)

For the complete list of available pack names see: Available IconPacks (only those with path!)

For more see:

dart run flutter_iconpicker:generate_packs --help

This dart cli program generates all IconPacks you need.

If you tend to change your IconPacks, you always have to re-run that command!

To make it easier you can setup this command easily as a pre-script running before launching your flutter app (For info on this if you use VSCode have a look at: https://code.visualstudio.com/docs/editor/tasks). This automates your development workcycle and for building release apps, just run that dart script before building.

fluttericonpicker's People

Contributors

ahmadre avatar alisson-suzigan avatar corioste avatar hoxuanvinh1999 avatar kechankrisna avatar lisuizhe avatar manerakai avatar mayank-9018 avatar mennovanhout avatar nstrelow avatar pk21-praveen avatar rebarah avatar samuel23taku avatar sno2 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

fluttericonpicker's Issues

Lib not compatible with the flutter stable track since ages

I am curious if this lib is still supported or just an outdated artifact? We always get in trouble after upgrading flutter. Last time we could establish a stable track compatibility by linking against your "hotfix" branch that is still not merged.

Is there any change that the flutter stable track compatibility is established again in near future?

very slow?

hey, thanks for this!
I'd love to try it out but its very slow for me.
I've read in another issue that it was debug only, so i tried building it and running it on my phone but it is still very slow. takes 3 seconds to open the picker, even scrolling through the icons is somewhat laggy.
I'm using the picker with font awesome icon pack, and using this package to get the font awesome icons (https://pub.dev/packages/font_awesome_flutter)
My phone is a samsung galaxy s8 plus.
if there's anything you need from me to help identify why this is happening then just let me know.
hope this gets fixed, looks like a great package tbh.
cheers mate

This application cannot tree shake icons fonts...

Flutter 2.8.1 โ€ข channel stable โ€ข https://github.com/flutter/flutter.git Framework โ€ข revision 77d935af4d (6 weeks ago) โ€ข 2021-12-16 08:37:33 -0800 Engine โ€ข revision 890a5fca2e Tools โ€ข Dart 2.15.1

When generating the apk I get this error:

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

  • file:///Users/carielo/FlutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.2/lib/Serialization/iconDataSerialization.dart:76:16

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/carielo/FlutterSDK/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1070

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

Process 'command '/Users/carielo/FlutterSDK/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.
    `

Spacing properties do not affect

Spacing do not affect
Following code is used to create the picker, however the main axis and cross axis spacing properties do not affect.

IconData? icon = await FlutterIconPicker.showIconPicker( context, adaptiveDialog: false, iconSize: 25, crossAxisSpacing: 30, mainAxisSpacing: 30, title: const Text("Select an icon") , barrierDismissible: false, constraints: BoxConstraints( maxHeight: 700, maxWidth: 340, minWidth: 320, ), iconPackModes: [IconPack.fontAwesomeIcons], ); if(icon!= null) { _categoryFormController.setIcon(icon); }

image

Sharp, rounded, outlined not supported but still appears

Hey there,

I have an issue with the IconPack.material : it's written in your readme file that Sharp, rounded, outlined are not supported, however they still appears in the list as shown below.
image

I would suggest to split the Material.dart file in four different files and be able to add them as you want.

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 :(

Update to Flutter 2.8 breaks package

With Flutter 2.8 the package breaks the build with the following message:

ERROR: ../../../.pub-cache/hosted/pub.dartlang.org/icon_picker-2.0.1/lib/material_icons.dart:38:27: Error: Member not found: 'six_ft_apart'.
../โ€ฆ/lib/material_icons.dart:38
ERROR:     'six_ft_apart': Icons.six_ft_apart,
ERROR:                           ^^^^^^^^^^^^
Exception: Build process failed

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,
                                  ^^^^^^^^^^^^^^^^^^

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.

Error: Getter not found: 'tripadvisor'

I am using flutter_iconpicker: ^3.0.4 with Flutter 2.5.2, I get the following error:

: Error: Getter not found: 'tripadvisor'.
../โ€ฆ/Packs/FontAwesome.dart:1407
  'tripadvisor': FontAwesomeIcons.tripadvisor,
                                  ^^^^^^^^^^^

Here is my code:

    final iconData = await FlutterIconPicker.showIconPicker(
      context,
      iconPackMode: IconPack.material,
      iconColor: AppColors.secondary,
      title: Text(
        widget.emptyText,
      ),
      closeChild: Text(
        S.current.close,
        textScaleFactor: _scaleFactorClose,
      ),
      searchHintText: S.current.search,
      noResultsText: S.current.noResultsFor,
    );

Is there a way to only show baseline Icon theme?

Hi,

I just started to implement your package and it's working very well but has duplicated icons (i.e. Outlined, Round, Sharp, etc.). Is there a way to only show the baseline ones? Without say editing the Packs\Material.dart file?

Icon displayed does not match key

The icon displayed in Dialog doesn't match with key.
Ex: key: border_bottom_outlined, icon displayed: arrow_left.
I'm using IconPack.material

Simulator Screen Shot - iPhone 8 - 2021-05-23 at 13 52 02

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

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, fontPackage and 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.
  }

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: apps-auth@4acd274

Box Icons getting displayed like 'X' marks

Hello,
In my use case, FlutterIconPicker will help the user to pick an icon, then this icon info is saved in some class. This class will be serialized to JSON and will be Stored/Retrieved from SharedPreferences as a configuration data.
While loading from shared preference, I get the iconCode correct, but after using it as Icon(IconData(iconCode)), I get a strange output as shown in following image:
Screenshot_2020-08-04-22-19-41-100_com example SMART
Note: Here the last item is added manually in the list, However, the first 3 items are fetched from SharedPreference and no exception has been thrown during fetching and populating the data!

// Code Snippet - Deserializing data holding class
SmartRoomData.fromJsonString(String rawJson) {
    try {
      rawJson = rawJson.replaceAll('\'', '\"');
      Map<String, dynamic> json = jsonDecode(rawJson);
      name = json['name'];
      icon = IconData(int.parse(json['icon']));
      smartIds = json['smartIds'];
    } catch (e) {
      print(e);
    }
  }

// Code Snippet - Serializing Data holding class
Map<String, dynamic> toJson() {
    return {
      'name': name,
      'icon': icon.codePoint.toString(),
      'smartIds': smartIds.toList(),
      'type': type,
    };
  }

  String toJsonString() {
    return jsonEncode(toJson());
  }

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.

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?

[How To] Create Map<String, IconData> 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?

IconManager.getSelectedPack() should include the customIconPack option

The search bar replaces the <String,IconData> map with the just material icons if the icon picker has a customIconPack, making the use of custom icon packs useless without a properly functioning search bar.

That is because IconManager.getSelectedPack returns "icons" if the IconPack enum is IconPack.custom

The method '+' was called on null at search Icon

I get this error if i can't found icon after search

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by widgets library โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following NoSuchMethodError was thrown building IconPicker(dirty, dependencies: [_LocalizationsScope-[GlobalKey#62a5e], _InheritedTheme], state: _IconPickerState#db38d):
The method '+' was called on null.
Receiver: null
Tried calling: +(" ")

The relevant error-causing widget was
    MaterialApp 
lib\main.dart:28
When the exception was thrown, this was the stack
#0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:53:5)
#1      _IconPickerState.build 
package:flutter_iconpicker/IconPicker/iconPicker.dart:69
#2      StatefulElement.build 
package:flutter/โ€ฆ/widgets/framework.dart:4619
#3      ComponentElement.performRebuild 
package:flutter/โ€ฆ/widgets/framework.dart:4502
#4      StatefulElement.performRebuild 
package:flutter/โ€ฆ/widgets/framework.dart:4675
...
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

After i check in your file , I think you forgot to add default noResultText in your constructor.

Error Line

Wrap(
              spacing: 5,
              runSpacing: 10,
              children: IconPicker.iconMap.length != 0
                  ? iconList
                  : [
                      Center(
                        child: Text(widget.noResultsText +
                            ' ' +
                            SearchBar.searchTextController.text),
                      )
                    ]),

Your Constructor

class IconPicker extends StatefulWidget {
  final double iconSize;
  final String noResultsText;
  static Function reload;
  static Map<String, IconData> iconMap;

  IconPicker({this.iconSize, this.noResultsText, Key key}) : super(key: key);

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

If i added property noResultsText in FlutterIconPicker.showIconPicker(context, iconSize: 40, noResultsText: 'Not found my bro'); error is gone.

I hope you added default noResultText or make it required in your constructor.

Flutterflow build error

Hi,

Thank you so much for creating this package.

I'm using FlutterFlow and implemented the package into my app. It works great on all the testing devices but when I build the apk, it's showing this error. I'm using v3.2.4 since the latest version has a package conflict with FlutterFlow. Any ideas why it's showing this error? Much appreciated your help!

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

  • file:///Users/[user]/.pub-cache/hosted/pub.dev/flutter_iconpicker-3.2.4/lib/Serialization/iconDataSerialization.dart:76:16
    Target aot_android_asset_bundle failed: Error: Avoid non-constant invocations of IconData or try to build again with --no-tree-shake-icons.

This application cannot tree shake icons fonts

When I run the following command
flutter build apk --split-per-abi

I get this error and fail the apk building process

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

  • file:///C:/Users/ameen/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.3/lib/Serialization/iconDataSerialization.dart:76:16

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102

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

Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1`

Adobe icon not available in FontAwesome 5.15, fails compile

fluttercommunity/font_awesome_flutter#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,
                            ^^^^^

Optimize app size by loading icons on demand remotely

Issue Description:
Currently, all the Icons need to be embedded with the binary, which causes the app to be larger than it needs to be. This increases the app's installation size and consumes unnecessary device storage. To improve the app's efficiency and reduce its size, it would be ideal to implement a solution that loads icons on demand through network requests and saves only the icons chosen by the user to the disk during runtime.

Issue Details:

  1. The current approach of embedding all icons within the binary is causing the app's size to be larger than necessary. This adversely affects the user experience by increasing installation time and consuming more device storage space.
  2. An optimized solution is desired where icons are fetched from the network on demand. This means that icons should only be downloaded and loaded into memory when they are required by the user.
  3. When a user selects an icon, it should be saved to disk for future use, eliminating the need for repeated network requests. By storing selected icons locally, the app can load them from the device's storage instead of fetching them over the network.
  4. Icons that have not been selected by the user should not be stored permanently on the device. Instead, they should be fetched from the network whenever needed and discarded from memory when no longer in use.
  5. The implementation should ensure a seamless user experience with minimal latency. Users should not experience any significant delays when loading icons or selecting them.
  6. Care should be taken to handle scenarios where the network connection is poor or unavailable. In such cases, the app should gracefully handle the situation and provide appropriate feedback to the user.
  7. The solution should be implemented in a way that allows easy scalability and future additions of new icons. The app should be able to fetch and save icons without major code changes or disruptions.

Expected Outcome:
By implementing this solution, the app's installation size will be significantly reduced as only selected icons are saved to the disk. Users will experience faster installation times and utilize less storage space on their devices. Additionally, the dynamic loading of icons on demand will improve the app's performance and enhance the overall user experience.

Build fails in Flutter 3.0

It was working fine. Today I just updated my flutter to Flutter 3.0.
Now, when I flutter 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]

Whatsapp icon dissappeared in flutter 3.7

Hello,
After upgrading to flutter 3.7, i get the following error : flutter_iconpicker-3.2.2/lib/IconPicker/Packs/Material.dart:25632:21: Error: Member not found: 'whatsapp'.
It seems that icon does not exist anymore !?

Icons missing, can't compile app

flutter_iconpicker: 3.1.4+1

.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.4+1/lib/IconPicker/Packs/Material.dart:1231:27: Error: Member not found: 'class__rounded'.
  'class__rounded': Icons.class__rounded,
                          ^^^^^^^^^^^^^^
.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-3.1.4+1/lib/IconPicker/Packs/Material.dart:1232:28: Error: Member not found: 'class__outlined'.
  'class__outlined': Icons.class__outlined,

Is it slow to open or it's just me?

Great widget. Exactly what I need.
It's a little slow to start. The app freezes for 1-2 seconds before the the popup appears.
My device is OnePlus 3T.
Is it going in a loop generating all the icons every time?
Could we pre-generate an array of icons and put as a const array in dart file?

Expose search logic

I think it would be nice if the search logic were to be exposed for overwriting.

if (key.toLowerCase().contains(searchValue.toLowerCase())) {

e.g.

// signature
bool Function(String search, String icon)

FlutterIconPicker.showIconPicker(
 ...
 searchCompare: (search, icon) => search.toLowerCase().contains(icon.replaceAll('_', ' ').toLowerCase())
 ...
);

Here I simply added a string replace but I'd like to use a fuzzy search library like fuzzywuzzy

How do i use my own iconpack?

I tried creating a icon pack. and i want it as my 'customIconPack', but i don't understand this explanation:
/// Provide here your custom IconPack in a [Map<String, IconData>]
/// to show your own collection of Icons to pick from

can you give me more detail on what to do after i changed my iconPackMode to custom?
thanks

Error : "Synchronous waiting using dart:cli waitFor"

Hey,

Using the provided command at the bottom of the README, I get the following error :

> dart run flutter_iconpicker:generate_packs --packs material
Building package executable... 
Built flutter_iconpicker:generate_packs.
Unhandled exception:
Synchronous waiting using dart:cli waitFor and C API Dart_WaitForEvent is deprecated and disabled by default. This feature will be fully removed in Dart 3.4 release. You can currently still enable it by passing --enable_deprecated_wait_for to the Dart VM. See https://dartbug.com/52121.
dart:cli-patch/cli_patch.dart 9:47                                                                          _waitForEvent
dart:cli/wait_for.dart 64:12                                                                                _WaitForUtils.waitForEvent
dart:cli/wait_for.dart 152:19                                                                               waitFor
package:dcli/src/util/wait_for_ex.dart 38:17                                                                waitForEx
package:dcli/src/functions/copy_tree.dart 73:5                                                              copyTree
C:\Users\Hugo\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_iconpicker-3.4.4\bin\generate_packs.dart 80:5  emptyIconPacks
C:\Users\Hugo\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_iconpicker-3.4.4\bin\generate_packs.dart 48:3  main
package:dcli/src/util/wait_for_ex.dart 35:28                                                                waitForEx
package:dcli/src/functions/copy_tree.dart 73:5                                                              copyTree
C:\Users\Hugo\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_iconpicker-3.4.4\bin\generate_packs.dart 80:5  emptyIconPacks
C:\Users\Hugo\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_iconpicker-3.4.4\bin\generate_packs.dart 48:3  main

(Also, the link to Models/IconPack is broken).

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

Missing icons

Greetings,

When I upgrade to the latest master it seems that there are two icons that have been removed from the latest Flutter master?

Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.0.2/lib/IconPicker/Packs/Material.dart:1864:30: Error: Getter not found: 'door_back_rounded'.
'door_back_rounded': Icons.door_back_rounded,

Local/Pub/Cache/hosted/pub.dartlang.org/flutter_iconpicker-3.0.2/lib/IconPicker/Packs/Material.dart:1869:32: Error: Getter not found: 'door_front_outlined'.
'door_front_outlined': Icons.door_front_outlined,
^^^^^^^^^^^^^^^^^^^

cupertino_icons has newer version 1.0.0

Could you check for compatibility with cupertino_icons 1.0.0 @Ahmadre ? Thanks

Error

Because flutter_iconpicker >=2.0.0 depends on cupertino_icons ^0.1.3 and StudyU_Designer depends on cupertino_icons ^1.0.0, flutter_iconpicker >=2.0.0 is forbidden.

serializeIcon returns wrong key

Hi,

I am using flutter_iconpicker version 3.0.1+2.
When using the method serializeIcon using the material pack I am not getting the correct key as output.
If using serializeIcon and deserializeIcon in chain I get the same IconData. However if I only use serializeIcon and check the store result in data base I do not get the correct Key.

For instance:

Example (serializeIcon)

  • Input: Icons.location_on
  • Output: {"key": "read_more_outlined", "pack": "material"}

Thank you !

Problem with Flutter 3.10

Xcode build done. 45,7s
Failed to build iOS app
Error (Xcode): ../../../.pub-cache/hosted/pub.dev/flutter_iconpicker-3.2.2/lib/Dialogs/DefaultDialog.dart:129:23: Error: 'SearchBar' is imported from both 'package:flutter/src/material/search_anchor.dart' and 'package:flutter_iconpicker/IconPicker/searchBar.dart'.
DefaultDialog.dart:129
Could not build the application for the simulator.
Error launching application on iPhone 14 Pro.
Exited

Remove search?

Hey, i want to remove the searchbar, because my iconpack is so small. Is it possible?

I'm having a failure when trying to build APK

Hi, I'm getting this error when I run "flutter build apk":

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

  • file:///Users/zara/devel/tools/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_iconpicker-2.2.2/lib/Serialization/iconDataSerialization.dart:22:14

It points to line 22 of iconDataSerialization.dart.

I'm a fairly novice app developer so no idea what to do about this. Any suggestions would be great

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.

Missing newest src from Github?

Hey @Ahmadre

Not sure if I am not looking at the right place, but Material.dart on Github is different than the one inside the package.

Maybe this is missing in Github?

  • Update MaterialIcons to pick through Icons rather then IconData

Was trying to fix #25, but the failing icons are not in Github yet ๐Ÿ™ˆ

Icons are not showing

Im getting No results for: message by default when i open the picker and even when i search i cant seem to find any icons.

onTap: () async => selectedIcon = await showIconPicker(
showSearchBar: false,
iconPackModes: [IconPack.allMaterial, IconPack.cupertino],
searchComparator: (String search, IconPickerIcon icon) =>
search.toLowerCase().contains(
icon.name.replaceAll('_', ' ').toLowerCase()) ||
icon.name
.toLowerCase()
.contains(search.toLowerCase()),
iconPickerShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
context,
title: const Text('Select badge icon')),

                  am i missing something?

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.