o_color_picker 1.0.2 o_color_picker: ^1.0.2 copied to clipboard
Simple and fast 2-step color picker, which supports shades and colors customization.
import 'package:flutter/material.dart';
import 'package:o_color_picker/o_color_picker.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'o_color_picker demo app',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Color? selectedColor = Colors.lightGreen[300];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(var states) => selectedColor!,
)),
child: Text(
'Change the color of the button',
style: TextStyle(
color: Colors.black,
),
),
onPressed: () => showDialog<void>(
context: context,
builder: (_) => Material(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
OColorPicker(
selectedColor: selectedColor,
colors: primaryColorsPalette,
onColorChange: (color) {
setState(() {
selectedColor = color;
});
Navigator.of(context).pop();
},
),
],
),
),
),
),
],
),
),
);
}
}