flutter hsv color picker
an hsv color picker inspired by chrome devtools and a material color picker for your flutter app.
getting started
installation
add this to your pubspec.yaml (or create it):
dependencies:
flutter_colorpicker: any
then run the flutter tooling:
flutter packages get
or upgrade the packages with:
flutter packages upgrade
example
use it in [showdialog] widget:
// create some value
color pickercolor = color(0xff443a49);
color currentcolor = color(0xff443a49);
valuechanged<color> oncolorchanged;
// bind some values with [valuechanged<color>] callback
changecolor(color color) {
setstate(() => pickercolor = color);
}
// raise the [showdialog] widget
showdialog(
context: context,
child: alertdialog(
title: const text('pick a color!'),
content: singlechildscrollview(
child: colorpicker(
pickercolor: pickercolor,
oncolorchanged: changecolor,
enablelabel: true,
pickerareaheightpercent: 0.8,
),
// use material color picker
// child: materialpicker(
// pickercolor: pickercolor,
// oncolorchanged: changecolor,
// enablelabel: true, // only on portrait mode
// ),
),
actions: <widget>[
flatbutton(
child: text('got it'),
onpressed: () {
setstate(() => currentcolor = pickercolor);
navigator.of(context).pop();
},
),
],
),
)
Comments are closed.