fluttericonpicker
this package provides an iconp,icker 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_iconp,icker
as a dependency in your pubspec.yaml file.
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:
- import:
import 'package:flutter_iconp,icker/serialization/icondataserialization.dart';
- call this to convert the picked icondata to a map:
icondata to map
icondatatomap(icondata)
- you can retreive the icondata by passing the mapped icondata:
map to icondata
maptoicondata(map)
example
import 'package:flutter/material.dart';
import 'package:flutter_iconp,icker/flutter_icon,picker.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()
)
])
),
);
}
}
Comments are closed.