Coder Social home page Coder Social logo

mchome / flutter_colorpicker Goto Github PK

View Code? Open in Web Editor NEW
339.0 7.0 198.0 2.13 MB

HSV(HSB)/HSL/RGB/Material color picker inspired by all the good design for your amazing flutter apps.

Home Page: https://pub.dev/packages/flutter_colorpicker

License: MIT License

Objective-C 0.02% Dart 97.36% HTML 2.31% Kotlin 0.07% Swift 0.24%
flutter color-picker material block grid flutter-package hsv hsb hsl rgb

flutter_colorpicker's Introduction

flutter_colorpicker

pub package badge

HSV(HSB)/HSL/RGB/Material color picker inspired by all the good design for your amazing flutter apps.
Adorable color pickers out of the box with highly customized widgets to all developers' needs.

Web Example

Getting Started

Use it in [showDialog] widget:

// create some values
Color pickerColor = Color(0xff443a49);
Color currentColor = Color(0xff443a49);

// ValueChanged<Color> callback
void changeColor(Color color) {
  setState(() => pickerColor = color);
}

// raise the [showDialog] widget
showDialog(
  context: context,
  child: AlertDialog(
    title: const Text('Pick a color!'),
    content: SingleChildScrollView(
      child: ColorPicker(
        pickerColor: pickerColor,
        onColorChanged: changeColor,
      ),
      // Use Material color picker:
      //
      // child: MaterialPicker(
      //   pickerColor: pickerColor,
      //   onColorChanged: changeColor,
      //   showLabel: true, // only on portrait mode
      // ),
      //
      // Use Block color picker:
      //
      // child: BlockPicker(
      //   pickerColor: currentColor,
      //   onColorChanged: changeColor,
      // ),
      //
      // child: MultipleChoiceBlockPicker(
      //   pickerColors: currentColors,
      //   onColorsChanged: changeColors,
      // ),
    ),
    actions: <Widget>[
      ElevatedButton(
        child: const Text('Got it'),
        onPressed: () {
          setState(() => currentColor = pickerColor);
          Navigator.of(context).pop();
        },
      ),
    ],
  ),
)

preview SlidePicker

Details in example folder.

flutter_colorpicker's People

Contributors

calebisstupid avatar drzwipercepcji avatar ekangal avatar friebetill avatar garv-shah avatar imgbotapp avatar imsamgarg avatar ionys320 avatar lastant avatar lig avatar luciano-cervantes avatar mchome avatar robertodoering avatar rostivan avatar sgehrman avatar shahir-abdulla avatar tsinis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_colorpicker's Issues

Is it possible to give values in _colorTypes:

Is it possible to give values in _colorTypes:

typedef ValueChanged <K, T> = void Function (K v, T value);

why?

Can be used to set the theme primarySwatch

是否可以给_colorTypes内的值:

typedef ValueChanged<K,T> = void Function(K v,T value);

why?

可用于设置主题 primarySwatch

 ThemeData(
      primarySwatch: $___$
      );

Doesn't work on Flutter Desktop (macos)

I get the following error thrown when trying to your the color picker on macos using flutter desktop.

It starts to work when I resize the window to a smaller phone-like size. But when the window is horizontal and big and I try to open a color picker dialog, only a blank route appears.

                                              
Reloaded 35 of 819 libraries in 2.299ms.
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performLayout():
flutter: LayoutBuilder does not support returning intrinsic dimensions.
flutter: Calculating the intrinsic dimensions would require running the layout callback speculatively, which
flutter: might mutate the live render object tree.
flutter: 
flutter: Widget creation tracking is currently disabled. Enabling it enables improved error messages. It can
flutter: be enabled by passing `--track-widget-creation` to `flutter run` or `flutter test`.
flutter: 
flutter: When the exception was thrown, this was the stack:
flutter: #0      _RenderLayoutBuilder._debugThrowIfNotCheckingIntrinsics.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:263:9)
flutter: #1      _RenderLayoutBuilder._debugThrowIfNotCheckingIntrinsics (package:flutter/src/widgets/layout_builder.dart:270:6)
flutter: #2      _RenderLayoutBuilder.computeMaxIntrinsicWidth (package:flutter/src/widgets/layout_builder.dart:222:12)
flutter: #3      RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #4      _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #5      RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #6      RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #7      RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #8      RenderConstrainedBox.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:227:32)
flutter: #9      RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #10     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #11     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #12     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #13     RenderFlex.computeMaxIntrinsicWidth.<anonymous closure> (package:flutter/src/rendering/flex.dart:577:60)
flutter: #14     RenderFlex._getIntrinsicSize (package:flutter/src/rendering/flex.dart:534:38)
flutter: #15     RenderFlex.computeMaxIntrinsicWidth (package:flutter/src/rendering/flex.dart:574:12)
flutter: #16     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #17     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #18     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #19     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #20     RenderFlex.computeMaxIntrinsicWidth.<anonymous closure> (package:flutter/src/rendering/flex.dart:577:60)
flutter: #21     RenderFlex._getIntrinsicSize (package:flutter/src/rendering/flex.dart:534:38)
flutter: #22     RenderFlex.computeMaxIntrinsicWidth (package:flutter/src/rendering/flex.dart:574:12)
flutter: #23     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #24     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #25     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #26     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #27     RenderFlex.computeMaxIntrinsicWidth.<anonymous closure> (package:flutter/src/rendering/flex.dart:577:60)
flutter: #28     RenderFlex._getIntrinsicSize (package:flutter/src/rendering/flex.dart:503:39)
flutter: #29     RenderFlex.computeMaxIntrinsicWidth (package:flutter/src/rendering/flex.dart:574:12)
flutter: #30     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #31     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #32     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #33     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #34     _RenderSingleChildViewport.computeMaxIntrinsicWidth (package:flutter/src/widgets/single_child_scroll_view.dart:469:20)
flutter: #35     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #36     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #37     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #38     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #39     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #40     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #41     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #42     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #43     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #44     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #45     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #46     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #47     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #48     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #49     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #50     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #51     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #52     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #53     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #54     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #55     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #56     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #57     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #58     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #59     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #60     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #61     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #62     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #63     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #64     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #65     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #66     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #67     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #68     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #69     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #70     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #71     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #72     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #73     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #74     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #75     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #76     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #77     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #78     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #79     RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:77:20)
flutter: #80     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #81     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #82     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #83     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #84     RenderPadding.computeMaxIntrinsicWidth (package:flutter/src/rendering/shifted_box.dart:170:20)
flutter: #85     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #86     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #87     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #88     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #89     RenderFlex.computeMaxIntrinsicWidth.<anonymous closure> (package:flutter/src/rendering/flex.dart:577:60)
flutter: #90     RenderFlex._getIntrinsicSize (package:flutter/src/rendering/flex.dart:554:58)
flutter: #91     RenderFlex.computeMaxIntrinsicWidth (package:flutter/src/rendering/flex.dart:574:12)
flutter: #92     RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1290:23)
flutter: #93     _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:291:23)
flutter: #94     RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1288:41)
flutter: #95     RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1476:12)
flutter: #96     RenderIntrinsicWidth.performLayout (package:flutter/src/rendering/proxy_box.dart:631:36)
flutter: #97     RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #98     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #99     RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #100    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #101    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #102    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #103    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #104    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #105    _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1232:11)
flutter: #106    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #107    RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:259:13)
flutter: #108    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #109    RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:392:13)
flutter: #110    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #111    RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:206:11)
flutter: #112    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #113    RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:206:11)
flutter: #114    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #115    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #116    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #117    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #118    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #119    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #120    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #121    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #122    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #123    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #124    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #125    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #126    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #127    RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #128    RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3146:13)
flutter: #129    RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
flutter: #130    RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #131    RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1578:7)
flutter: #132    PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:844:18)
flutter: #133    RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:341:19)
flutter: #134    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:762:13)
flutter: #135    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:280:5)
flutter: #136    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1031:15)
flutter: #137    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:973:9)
flutter: #138    SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:889:5)
flutter: #142    _invoke (dart:ui/hooks.dart:249:10)
flutter: #143    _drawFrame (dart:ui/hooks.dart:207:3)
flutter: (elided 3 frames from package dart:async)
flutter: 

Overflow on dialog / iPhone

Just tried the following:

showDialog(
      context: mainContext,
      builder: (context) {
        return AlertDialog(
          contentPadding: EdgeInsets.zero,
          content: SingleChildScrollView(
            child: picker.ColorPicker(
              valueState.value,
              (color) {
                valueState.value = color;
              },
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: const Text('Got it'),
              onPressed: () {
                RemoteManagerWidget.of(mainContext).onChanges(id, valueState.value);
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );

And it got me this:
Simulator Screen Shot - iPhone XS - 2019-05-27 at 20 47 53

Am I doing something wrong ?
I'm using v0.2.4 of the package and last flutter stable

Slider doesn't slide if set to white

I'm using ColorPicker.

If the color is initially set to white (topleft corner), or any color that touches the left side, the slider doesn't slide.

I'm sure there is some math reason for this, but to the user it seems like a bug. I kept thinking my app froze.

Same problem happens on SlidePicker. If V is to the left, then H and S sliders don't move. If s is 0, then H slider doesn't move.

get color of MaterialColor

Hello, thanks for package.
Have one question: How to get real Color Code (HEX, RGB...) of selected color?

I'm put "print()" in void changeColor(Color color) function, but return only "MaterialColor(primary value: Color(0xfff44336))".
How to get the color for MaterialColor?

For API payload need a color in HEX, not MaterialColor.

Thanks!

@edit
One friend help me. Get HEX for MaterialColor only use color.value.toRadixString(16).
Thx

Outline white Color[ For visibility in white dialogs]

See the image for better understanding.

Black color is outlined with some glitter ? So it's visible even with black colored dialog. [Image 1]
But if we turn the tables and make the dialog white. white is not visible any more. [Image 2]

So can you outlined the white color like you did with black color so it's visible to the user.

photo_2021-12-06_22-48-20
photo_2021-12-06_22-48-16

Jerky/jittery behavior when not inside an AlertDialog

When I place any of the color picker widgets inside an AlertDialog, they work great. But, when I put them directly in the widget tree, they don't work well. The behavior of dragging around the color cursor becomes very jittery and will sometimes jump around.

The issue is that I am updating my state in the onColorChanged callback, which in turn causes the pickerColor to change. Many colors can be represented by a number of different picker states (for example, black could be any hue) so when the pickerColor is changed, the ColorPicker jumps to an arbitrary state that could produce that color.

How do I prevent this? Why doesn't this behavior occur inside an AlertDialog? Is there a different way I am supposed to handle state? or is this a bug?

Have the possibility to input a List<Color> to CircleColorPicker

currently the List of colors is predefined to :

static const List colors = [
Color(0xffff0000),
Color(0xffffff00),
Color(0xff00ff00),
Color(0xff00ffff),
Color(0xff0000ff),
Color(0xffff00ff),
Color(0xffff0000)
];

I'd like to have the possibility to input my own color list to :
CircleColorPicker(
{Key key,
this.radius = 120,
this.initialColor = const Color(0xffff0000),
this.thumbColor = Colors.black,
this.thumbRadius = 8,

thank you !

showDialog in example code not working

../../development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-1.0.3/lib/src/palette.dart:1055:15: Error: No named parameter with the name 'label'.
label: widget.embeddedText ? const Text('Hex') : null,
^^^^^
../../development/flutter/packages/flutter/lib/src/material/input_decorator.dart:2517:9: Context: Found this candidate, but the arguments don't match.
const InputDecoration({

    ^^^^^^^^^^^^^^^

../../development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-1.0.3/lib/src/material_picker.dart:137:27: Error: No named parameter with the name 'dragDevices'.

Landscape version?

Would love an alternate layout that works in landscape format. Perhaps with the color square in the left and the sliders on the right. For reference see the date_picker.dart showDatePicker() dialog that displays differently depending on orientation.

Manual Hex Input

Would it be a possibility to add the ability to type a Hex color in?

Select color by code control

I want to flexibly control the selected color block through the code. I made a small demo and hardcoded a color 【0xffFFB400】 that did not exist in _defaultColors. When I selected the color. The expectation is that no color block will be selected, but when I click, it is still selected. The color block I clicked.
in debug mode, I found that _currColor value is 0xffFFB400, but widget is still select the wrong color block .

...
const List<Color> _defaultColors = [Color(0xfff44336),Color(0xffe91e63),Color(0xff9c27b0),Color(0xff673ab7),Color(0xff3f51b5),Color(0xff2196f3),Color(0xff03a9f4),Color(0xff00bcd4),Color(0xff009688),Color(0xff4caf50),Color(0xffcddc39),Color(0xffff9800)];
....
void changeColor(Color color) => setState(() => _currColor = Color(0xffFFB400));
...
SingleChildScrollView(child:BlockPicker(availableColors: _defaultColors, pickerColor: _currColor, onColorChanged: changeColor

A block color picker

A typical color picker in mobile platform.
Will ship with these custom features:

  • color array
  • item shape
  • block layout

Null value support

Hi. Thanks for your work.

I'm experimenting with wrapping BlockPicker to use as reactive_forms control.
It seems that BlockPicker lacks of null value support for pickerColor value.

The form initial state could be empty(if creating a new record) - currently pickerColor: null causes an error so it requires to make pickerColor: value ?? Colors.transparent.

The other thing is lack of uncheck support for the picker.

How to work around using the colorpicker inside an alertdialog on a small phone (e.g. nexus5)

03-10 15:24:00.632  1140  1178 I flutter : ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
03-10 15:24:00.641  1140  1178 I flutter : The following message was thrown during layout:
03-10 15:24:00.641  1140  1178 I flutter : A RenderFlex overflowed by 43 pixels on the right.
03-10 15:24:00.671  1140  1178 I flutter : The overflowing RenderFlex has an orientation of Axis.horizontal.
03-10 15:24:00.671  1140  1178 I flutter : The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
03-10 15:24:00.671  1140  1178 I flutter : black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
03-10 15:24:00.671  1140  1178 I flutter : Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
03-10 15:24:00.671  1140  1178 I flutter : RenderFlex to fit within the available space instead of being sized to their natural size.
03-10 15:24:00.671  1140  1178 I flutter : This is considered an error condition because it indicates that there is content that cannot be
03-10 15:24:00.671  1140  1178 I flutter : seen. If the content is legitimately bigger than the available space, consider clipping it with a
03-10 15:24:00.671  1140  1178 I flutter : ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
03-10 15:24:00.671  1140  1178 I flutter : like a ListView.
03-10 15:24:00.671  1140  1178 I flutter : The specific RenderFlex in question is:
03-10 15:24:00.671  1140  1178 I flutter :   RenderFlex#0d25a relayoutBoundary=up1 OVERFLOWING
03-10 15:24:00.671  1140  1178 I flutter :   creator: Row ← Column ← ConstrainedBox ← Container ← ColorPicker ← _SingleChildViewport ←
03-10 15:24:00.671  1140  1178 I flutter :   _ScrollableScope ← IgnorePointer-[GlobalKey#66b26] ← Semantics ← Listener ← _GestureSemantics ←
03-10 15:24:00.671  1140  1178 I flutter :   RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#cd00a] ← ⋯
03-10 15:24:00.671  1140  1178 I flutter :   parentData: offset=Offset(0.0, 271.0); flex=null; fit=null (can use size)
03-10 15:24:00.671  1140  1178 I flutter :   constraints: BoxConstraints(0.0<=w<=232.0, 0.0<=h<=Infinity)
03-10 15:24:00.671  1140  1178 I flutter :   size: Size(232.0, 78.0)
03-10 15:24:00.671  1140  1178 I flutter :   direction: horizontal
03-10 15:24:00.671  1140  1178 I flutter :   mainAxisAlignment: center
03-10 15:24:00.671  1140  1178 I flutter :   mainAxisSize: max
03-10 15:24:00.671  1140  1178 I flutter :   crossAxisAlignment: center
03-10 15:24:00.671  1140  1178 I flutter :   textDirection: ltr
03-10 15:24:00.672  1140  1178 I flutter :   verticalDirection: down
03-10 15:24:00.672  1140  1178 I flutter : ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
03-10 15:24:00.672  1140  1178 I flutter : ════════════════════════════════════════════════════════════════════════════════════════════════════

Color picker type MaterialPicker visibility problem

I am using FormBuilderColorPicker(colorPickerType: ColorPickerType.MaterialPicker).
This is a very nice picker, but it has a problem. Many users complain that they cannot see which color they have chosen. If you look closely, the selected color is surrounded by very faint lines in the same color. They are almost invisible. If the lines were black, there would be no problem to see what you have chosen.

App can't debug when colorpicker is added to the pubspec.yaml

I get the following output, followed by the usual "BUILD FAILED"

../../../.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-0.5.0/lib/src/hsv_picker.dart:730:43: Error: The parameter 'event' of the method 'AlwaysWinPanGestureRecognizer.addAllowedPointer' has type 'PointerDownEvent', which does not match the corresponding type, 'PointerEvent', in the overridden method, 'DragGestureRecognizer.addAllowedPointer'.
 - 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../../../development/flutter/packages/flutter/lib/src/gestures/events.dart').
 - 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../../../development/flutter/packages/flutter/lib/src/gestures/events.dart').
Change to a supertype of 'PointerEvent', or, for a covariant parameter, a subtype.
  void addAllowedPointer(PointerDownEvent event) {
                                          ^

../../../development/flutter/packages/flutter/lib/src/gestures/monodrag.dart:256:8: Context: This is the overridden method ('addAllowedPointer').
  void addAllowedPointer(PointerEvent event) {

I've completely cleaned flutter and downloaded all packages after the error showed up. Didn't work.

Add HCT Color Picker

Article from Material Design Blog

Material Design 3 uses a new color system called HCT (hue, chroma, tone). HCT is a new color system that perceptually accurate developed by Google for design. The color system that mostly used by designers today is HSL, but HSL (hue, saturation, lightness) isn’t remotely accurate, it doesn't ensure appropriate color contrast, accessibility standards, and consistent lightness/colorfulness across hues.

image

material_color_utilities package implements HCT, and can be used as a dependency. Flutter sdk currently depends on material_color_utilities, so it is not an additional dependency to projects. (flutter sdk pubspec.yaml)

The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent' Linux

When using the color picker on Linux I get following build error:

Launching lib/main.dart on Linux debug mode...
Building Linux application...
Error: ../../.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-0.4.0/lib/src/hsv_picker.dart:731:29: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
Error:  - 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../../flutter/package/lib/src/gestures/events.dart').
Error:  - 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../../flutter/package/flutter/lib/src/gestures/events.dart').
Error:     super.addAllowedPointer(event);
Error:                             ^
Exception: Build process failed

Version 0.3.5 not published?

I can't select version 0.3.5 in my pubspec - the latest is 0.3.4 (despite this repo having a 0.3.5 with the new MultipleChoiceBlockPicker).

Do you have to pull some levers to publish it?

whenever i add this library to the code i got this error

../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-1.0.3/lib/src/palette.dart:1055:15: Error: No named parameter with the name 'label'.
label: widget.embeddedText ? const Text('Hex') : null,
^^^^^
../../snap/flutter/common/flutter/packages/flutter/lib/src/material/input_decorator.dart:2517:9: Context: Found this candidate, but the arguments don't match.
const InputDecoration({
^^^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-1.0.3/lib/src/material_picker.dart:137:27: Error: No named parameter with the name 'dragDevices'.
.copyWith(dragDevices: PointerDeviceKind.values.toSet()),
^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-1.0.3/lib/src/material_picker.dart:200:23: Error: No named parameter with the name 'dragDevices'.
.copyWith(dragDevices: PointerDeviceKind.values.toSet()),
^^^^^^^^^^^

Colorpicker throwing an exception in web

Hi,

the flutter_colorpicker is throwing an exception in the web-version.

This happens as soon as I pick a color.

In the build-version Another exception was thrown: Instance of 'minified:ep<void>'

In the development-version I get a very long error:

stack_trace_mapper.js:261 Uncaught Bad state: Source maps are not done loading.
    at Object.a (http://localhost:42747/stack_trace_mapper.js:261:3)
    at ct.k6 (http://localhost:42747/stack_trace_mapper.js:2650:23)
    at Object.iH (http://localhost:42747/stack_trace_mapper.js:218:69)
    at jy (http://localhost:42747/stack_trace_mapper.js:2371:10)
    at Object.<anonymous> (http://localhost:42747/stack_trace_mapper.js:2365:42)
    at dart._StackTrace.new.toString (http://localhost:42747/dart_sdk.js:6060:29)
    at Object._toString [as toString] (http://localhost:42747/dart_sdk.js:4431:26)
    at new assertions.DiagnosticsStackTrace.new (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:3467:212)
    at binding$.FlutterErrorDetailsForPointerEventDispatcher.new.debugFillProperties (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:3209:24)
    at http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:2313:38
    at assertions._FlutterErrorDetailsNode.new.get builder (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:2316:28)
    at assertions._FlutterErrorDetailsNode.new.get builder [as builder] (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:3481:27)
    at assertions._FlutterErrorDetailsNode.new.getProperties (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:2328:54)
    at diagnostics$.TextTreeRenderer.new.[_debugRender] (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:1137:37)
    at diagnostics$.TextTreeRenderer.new.render (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:1051:34)
    at Function.dumpErrorToConsole (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:3315:142)
    at Function.reportError (http://localhost:42747/packages/flutter/src/foundation/debug.dart.js:3404:76)
    at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:42747/packages/flutter/src/gestures/binding.dart.js:144:35)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerEvent] (http://localhost:42747/packages/flutter/src/gestures/binding.dart.js:117:14)
    at binding$5.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:42747/packages/flutter/src/gestures/binding.dart.js:91:34)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:42747/packages/flutter/src/gestures/binding.dart.js:82:65)
    at Object._invoke1 (http://localhost:42747/dart_sdk.js:164821:7)
    at _engine.EngineWindow.new.invokeOnPointerDataPacket (http://localhost:42747/dart_sdk.js:162115:15)
    at _engine.PointerBinding.__.[_onPointerData] (http://localhost:42747/dart_sdk.js:142725:24)
    at http://localhost:42747/dart_sdk.js:143062:26
    at http://localhost:42747/dart_sdk.js:143027:16
    at HTMLElement.<anonymous> (http://localhost:42747/dart_sdk.js:142805:11)

Option for temperature picker

  1. Is there an option to create a gradient color picker from orange to white to blue?.
  2. Can the gradient color picker return values in color temperature (1700 - 9500 K I think is the range).

white_gradient

For bigger color temperature range it will look like this

image

PR broke a nice feature.

This the current status of block picker.(Video 1) As you can see when I change color on selecting new color. It doesn't show check mark on the newly selected color. ( Video recorded from the web page).

Luckily i had the old version of this package. And you can see how it used to work in older versions. (Video 2). Whenever i select new color. It shows i tick mark on that color.

I compared both the version and find out that the above commit broke this feature. Particularly this line

Link to commit

&& (widget.pickerColor.value == color.value),

Can you fix this ?

9rlISShDD8.mp4
video_2021-12-06_23-21-04.mp4

Error message shows up on console under "ColorPicker'

Hi, the package works as expected and I really like it. Don't know if this is a bug or something. But I do see the following pops up on the console under debug mode.

D/skia (16876): ERROR: 0:6: 'inout' : invalid qualifier: can be only used with function parameters

Full null safe release

Hey.

With Flutter 2.0 released, could we get a full release of 0.4.0? I use this package on another package of mine and by using a pre release (-nullsafety.0) pub gives me warnings when publishing new versions.

Thanks for this package!

iPhone 5s Landscape Material Dialog too large

If you run iPhone 5s in Landscape and pop the Material Dialog from your example, the height is too large and causes horizontal and vertical scrolling. Since these are just empty strips of color there is no reason that it can't be sized to properly fit without additional horizontal scrolling.

LayoutBuilder type

typedef LayoutBuilder = Widget Function(

in one of your classes BlockPicker you're using a type LayoutBuilder which is already defined in the flutter core widgets and will cause issues when using your library, please rename it to something else like BlockLayoutBuilder or something

hexInputController causes setState() called after dispose() exception

The code that throws this exception.
This exception is thrown when I close the Dialog and open it again, and is not thrown once I remove the controller.

class ColorPickerTextField extends StatefulWidget {
  const ColorPickerTextField(
      {Key? key, required this.color, this.onColorChanged})
      : super(key: key);
  final Color color;
  final void Function(String)? onColorChanged;

  @override
  _ColorPickerTextFieldState createState() => _ColorPickerTextFieldState();
}

class _ColorPickerTextFieldState extends State<ColorPickerTextField> {
  late Color _color;
  final _controller = TextEditingController();

  @override
  void initState() {
    super.initState();
    _color = widget.color;
    _controller.text = _color.value.toRadixString(16).toUpperCase();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return TextFormField(
        fillColor: _color,
        hoverColor: _color,
        readOnly: true,
        textColor:
            (_color.red * 0.299 + _color.green * 0.587 + _color.blue * 0.114) >
                    186
                ? ColorProvider.kDarkBlue
                : Colors.white,
        controller: _controller,
        onTap: () => showDialog(
              context: context,
              builder: (_) => AlertDialog(
                title: Text(
                  'Pick a color!',
                ),
                content: SingleChildScrollView(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      ColorPicker(
                        displayThumbColor: true,
                        hexInputController: _controller,
                        pickerColor: _color,
                        onColorChanged: (color) {
                          setState(() {
                            _color = color;
                          });
                        },
                        showLabel: true,
                        pickerAreaHeightPercent: 0.8,
                      ),
                      Container(
                        width: 300,
                        padding: const EdgeInsets.all(16),
                        child: TextFormField(
                          controller: _controller,
                          autofocus: true,
                          ),
                          maxLength: 8,
                          inputFormatters: [
                            UpperCaseTextFormatter(),
                            FilteringTextInputFormatter.allow(
                              RegExp(kValidHexPattern),
                            ),
                          ],
                        ),
                      )
                    ],
                  ),
                ),
                actions: <Widget>[
                  CustomOrangeTextButton(
                    onTap: () => Navigator.of(context).pop(),
                    text: 'Done',
                  ),
                ],
              ),
            ));
  }
}

class UpperCaseTextFormatter extends TextInputFormatter {
  @override
  TextEditingValue formatEditUpdate(oldValue, TextEditingValue newValue) =>
      TextEditingValue(
          text: newValue.text.toUpperCase(), selection: newValue.selection);
}

Null safety support

I'm going to submit a PR for the null safety support.

It is a common practice to keep such a code in a separate branch, i.e. null-safety, to be able to support the main release in legacy mode whilst the null safety compatible release could be released from its branch.

Please, prepare the branch for null safety support PR.

Target dart2js failed: Exception

Target dart2js failed: Exception:
../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-0.5.0/lib/src/hsv_picker.dart:730:43:
Error: The parameter 'event' of the method 'AlwaysWinPanGestureRecognizer.addAllowedPointer' has type 'PointerDownEvent',
which does not match the corresponding type, 'PointerEvent', in the overridden method,
'DragGestureRecognizer.addAllowedPointer'.

  • 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart'
    ('../../../flutter/packages/flutter/lib/src/gestures/events.dart').
  • 'PointerEvent' is from 'package:flutter/src/gestures/events.dart'
    ('../../../flutter/packages/flutter/lib/src/gestures/events.dart').
    void addAllowedPointer(PointerDownEvent event) {
    ^
    ../../../flutter/packages/flutter/lib/src/gestures/monodrag.dart:256:8:
    Info: This is the overridden method ('addAllowedPointer').
    void addAllowedPointer(PointerEvent event) {
    ^
    Error: Compilation failed.

Remove Drop Down Menu

Hello, i want to disable the ability to change the Colors Type and lock it to be HEXA only. i don't want users to be able to change it as it causes issues in my code.

Is there any way to remove the drop down menu or just disable it?

color selection "dots" are blurry

Hi,
I noticed that the color selector from the example code given, displays round circles that have a weird shadow to them. I'm not sure if this is an issue with the code, or it was intentional, but how can I get rid of this. Thanks - Joseph

Breaks on Landscape mode

Hi,

If the dialog is open and the user rotates the device from Portrait to Landscape the popup works. When closed and reopened the correct layout is used. Any workaround on orientation changing while the dialog is active? Much appreciated!

Error after installing v0.5.0

`../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-0.5.0/lib/src/hsv_picker.dart:730:43: Error: The parameter 'event' of the method 'AlwaysWinPanGestureRecognizer.addAllowedPointer' has type 'PointerDownEvent', which does not match the corresponding type, 'PointerEvent', in the overridden method, 'DragGestureRecognizer.addAllowedPointer'.

  • 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../../flutter/packages/flutter/lib/src/gestures/events.dart').
  • 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../../flutter/packages/flutter/lib/src/gestures/events.dart').
    Change to a supertype of 'PointerEvent', or, for a covariant parameter, a subtype.
    void addAllowedPointer(PointerDownEvent event) {
    ^

../../flutter/packages/flutter/lib/src/gestures/monodrag.dart:256:8: Context: This is the overridden method ('addAllowedPointer').
void addAllowedPointer(PointerEvent event) {
^
2

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/sam/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command '/Users/sam/Documents/flutter/bin/flutter'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 16s
`

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.