Giter Club home page Giter Club logo

pyozer / flutter_material_color_picker Goto Github PK

View Code? Open in Web Editor NEW
75.0 75.0 38.0 1.3 MB

Material color picker, you can customize colors. Selection in two step, first main color and after shades.

Home Page: https://pub.dartlang.org/packages/flutter_material_color_picker

License: MIT License

Dart 69.64% Kotlin 0.78% Swift 5.85% Objective-C 0.19% HTML 9.32% Ruby 14.21%
android color-picker dart dart2 flutter ios material-design widget

flutter_material_color_picker's Introduction

Flutter Material Color Picker pub package

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.2.0

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.

Example of usages

You can insert the color picker into a Dialog

Display color

You can use CircleColor widget, to display the selected color into your settings for example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.