o_color_picker 1.0.2 icon indicating copy to clipboard operation
o_color_picker: ^1.0.2 copied to clipboard

Simple and fast 2-step color picker, which supports shades and colors customization.

example/lib/main.dart

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();
                        },
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
14
likes
140
pub points
82%
popularity

Publisher

unverified uploader

Simple and fast 2-step color picker, which supports shades and colors customization.

Homepage
View/report issues

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

equatable, flutter

More

Packages that depend on o_color_picker