flutter_iconpicker 0.1.1 flutter_iconpicker: ^0.1.1 copied to clipboard
A Dialog for picking Icons in Flutter and use them anywhere
FlutterIconPicker #
This package provides an IconPicker with all Material 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.
Usage #
To use this package, add flutter_iconpicker
as a dependency in your pubspec.yaml file.
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,
iconSize: 40,
iconPickerShape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
title: Text('Pick an icon',
style: TextStyle(fontWeight: FontWeight.bold)),
closeChild: Text(
'Close',
textScaleFactor: 1.25,
),
searchHintText: 'Search icon...',
noResultsText: 'No results for:'
);
_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()
)
])
),
);
}
}