flutter_iconpicker 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

FlutterIconPicker #

This package provides an IconPicker with supported 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 #

IconPackSupported
Material
Material Outline
Cupertino
FontAwesome
LineAwesome

Usage #

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

[New] IconPackMode #

You can now select the wished IconPack through the new argument: iconPackMode. This defaults to IconPack.material. For further usage have a look in the example.

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. Import:
  import 'package:flutter_iconpicker/Serialization/iconDataSerialization.dart';
  1. Call this to convert the picked IconData to a Map:

IconData to Map

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

Map to IconData

  mapToIconData(map)

Example #

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> {
  Widget _icon;

_pickIcon() async {
  IconData icon = await FlutterIconPicker.showIconPicker(context, iconPackMode: 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()
          )
        ])
      ),
    );
  }
}

[1.1.1] - 31.03.2020 #

  • Fixed FontAwesome import

[1.1.0] - 21.03.2020 #

  • Add new IconPacks: Material Outline, Cupertino, LineAwesome, FontAwesome
    • Fixes: #2
  • Refactor IconPacks
  • Add iconPackMode

[0.8.2] - 20.03.2020 #

  • Add default values
    • Fixes: #3
  • Swiped last search

[0.1.5] - 11.01.2020 #

  • Improve performance with loading icons on showIconPicker
    • render icons async
    • add const where possible

[0.1.4] - 07.01.2020 #

  • Support Light & Dark Mode with:
    • Theme.of(context).dialogBackgroundColor for LinearGradient

[0.1.3] - 02.01.2020 #

  • Add Serialization for persisting IconData
    • iconDataToMap(iconData)
    • mapToIconData(map)
  • Add additional information in Readme

[0.1.2] - 19.12.2019 #

  • Add example project

[0.1.0] - 16.12.2019 #

  • Add scrollable Material Icons
  • Add SearchBar
  • Add CloseButton
  • Add arguments for picker

example/lib/main.dart

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> {
  Widget _icon;

  _pickIcon() async {
    IconData icon = await FlutterIconPicker.showIconPicker(context,
        iconPackMode: 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())
          ])),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_iconpicker: ^1.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_iconpicker/flutter_iconpicker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
77
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
99
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/IconPicker/Packs/FontAwesome.dart. (-0.50 points)

Analysis of lib/IconPicker/Packs/FontAwesome.dart reported 1 hint:

line 2 col 8: Don't import implementation files from another package.

Maintenance suggestions

The package description is too short. (-1 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flutter 0.0.0
font_awesome_flutter ^8.7.0 8.8.1
line_awesome_icons ^1.0.4+2 1.0.4+2
outline_material_icons ^0.1.1 0.1.1
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test