Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter material color picker

material color picker is a flutter widget, that can be customizable.

by default, it’s material colors, but you can define your own colors.

you can also use circlecolor widget to display color in your app. example, you can set the color picker in a dialog and display the selected color in a listtile, for settings.

how to use it

these examples use a static color for ‘selectedcolor’, but you can use a variable (state)

add to your flutter project

you just need to add flutter_material_color_picker as a dependency in your pubspec.yaml file.

flutter_material_color_picker: ^1.0.3

import

import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';

basic

materialcolorpicker(
    oncolorchange: (color color) {
        // handle color changes
    },
    selectedcolor: colors.red
)

listen main color changes

materialcolorpicker(
    oncolorchange: (color color) {
        // handle color changes
    },
    onmaincolorchange: (colorswatch color) {
        // handle main color changes
    },
    selectedcolor: colors.red
)

disallow shades

materialcolorpicker(
    allowshades: false, // default true
    onmaincolorchange: (colorswatch color) {
        // handle main color changes
    },
    selectedcolor: colors.red
)

if allowshades is set to false then only main colors will be shown and allowed to be selected.
oncolorchange will not be called, use onmaincolorchange instead.

custom colors

in this example, custom colors are a list of material colors (class who extend of colorswatch).
but you can create your own list of colorswatch.

materialcolorpicker(
    oncolorchange: (color color) {
        // handle color changes
    },
    selectedcolor: colors.red,
    colors: [
        colors.red,
        colors.deeporange,
        colors.yellow,
        colors.lightgreen
    ],
)

screenshot

color selection

there is two step, first choose the main color, and when you press it, you have to choose a shade of the main color.
by default it’s all material colors, but you can define custom colors, a list of colorswatch.

shade_color

main_color

example of usages

you can insert the color picker into a dialog

color picker

shade_color_dialog

display color

you can use circlecolor widget, to display the selected color into your settings for example.

example_circle_color


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.