搜索插件、代码仓与 APP 分类

GitHub 代码仓Pyozer/flutter_material_color_picker

flutter_material_color_picker

Material 颜色选择器,您可以自定义颜色。分两步选择,先选择主色调,再选择明暗变化。

flutter_material_color_picker 项目封面
星标
74
复刻
38
最近推送(UTC)
2023年5月31日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

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.

Main color selection Shade color selection
Example of usages

You can insert the color picker into a Dialog

Example main color in a dialog Example shade color in a dialog
Display color

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

Example of circlecolor widget in ListTile
Jean-Charles Moussé GitHub avatar
GitHub 作者

Jean-Charles Moussé ↗

Mobile (Android, iOS, Flutter) and Web (React, JS, PHP) developer.

AffluencesSarthe, France官方网站 ↗
语言DartRubyHTMLSwiftKotlinObjective-C

分类

此仓库发布的插件

使用的依赖

依赖清单 2 项

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗