ColourPicker class

A full colour picker: a palette area, sliders, a preview and colour labels, laid out side by side or stacked depending on the screen.

The palette area shows two properties of the colour at once, and the slider next to it controls a third. paletteType chooses which.

ColourPicker(
  pickerColour: _colour,
  onColourChanged: (c) => setState(() => _colour = c),
  hexInputBar: true,
)
Inheritance
Available extensions

Constructors

ColourPicker({Key? key, required Color pickerColour, required ValueChanged<Color> onColourChanged, HSVColor? pickerHsvColour, ValueChanged<HSVColor>? onHsvColourChanged, PaletteType paletteType = PaletteType.hsvWithHue, bool enableAlpha = true, @Deprecated('Use empty list in [labelTypes] to disable label.') bool showLabel = true, List<ColorLabelType> labelTypes = const [ColorLabelType.rgb, ColorLabelType.hsv, ColorLabelType.hsl], @Deprecated('Use Theme.of(context).textTheme.bodyText1 & 2 to alter text style.') TextStyle? labelTextStyle, bool displayThumbColor = false, bool portraitOnly = false, double colourPickerWidth = 300.0, double pickerAreaHeightPercent = 1.0, BorderRadius pickerAreaBorderRadius = BorderRadius.zero, bool hexInputBar = false, TextEditingController? hexInputController, List<Color>? colorHistory, ValueChanged<List<Color>>? onHistoryChanged})
Creates a colour picker starting at pickerColour.
const

Properties

colorHistory → List<Color>?
Previously picked colours, shown as swatches the user can tap.
final
colourPickerWidth → double
The width of the picker in logical pixels.
final
displayThumbColor → bool
Whether the slider thumbs are filled with the colour they select.
final
enableAlpha → bool
Whether to show an opacity slider and include opacity in the labels and hex value.
final
hashCode → int
The hash code for this object.
no setterinherited
hexInputBar → bool
Whether to show a text field for typing a hex value.
final
hexInputController → TextEditingController?
A controller for your own hex text field, kept in sync with the picker.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
labelTextStyle → TextStyle?
The text style of the labels.
final
labelTypes → List<ColorLabelType>
Which colour formats to show in the labels. Pass an empty list to hide them.
final
makeRefreshable → Widget

Available on Widget?, provided by the WidgetExtension extension

Places an empty ListView behind this widget so a RefreshIndicator can be used with content that doesn't scroll on its own.
no setter
onColourChanged → ValueChanged<Color>
Called with the new colour every time the user changes it.
final
onHistoryChanged → ValueChanged<List<Color>>?
Called with the updated history when the user saves a colour to it.
final
onHsvColourChanged → ValueChanged<HSVColor>?
Called with the new colour as HSV every time the user changes it.
final
paletteType → PaletteType
Which two properties the palette area controls, and so which property the main slider controls.
final
pickerAreaBorderRadius → BorderRadius
The corner rounding of the palette area.
final
pickerAreaHeightPercent → double
The height of the palette area as a fraction of its width. 1.0 makes it square.
final
pickerColour → Color
The colour shown when the picker first appears, and whenever it changes.
final
pickerHsvColour → HSVColor?
The starting colour as HSV. Overrides pickerColour when set.
final
portraitOnly → bool
Whether to always use the stacked (portrait) layout, even on wide screens.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showLabel → bool
Whether to show the colour value labels.
final

Methods

center({double? heightFactor, double? widthFactor}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Centres this widget in the available space.
cornerRadiusWithClipRRect(double radius) → ClipRRect

Available on Widget?, provided by the WidgetExtension extension

Clips this widget to a rectangle with all corners rounded by radius.
cornerRadiusWithClipRRectOnly({int bottomLeft = 0, int bottomRight = 0, int topLeft = 0, int topRight = 0}) → ClipRRect

Available on Widget?, provided by the WidgetExtension extension

Clips this widget to a rectangle with a different radius on each corner. Corners you leave out stay square.
createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<ColourPicker>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
expand({int flex = 1}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Wraps this widget in an Expanded so it fills the remaining space in a Row, Column or Flex.
fit({BoxFit? fit, AlignmentGeometry? alignment}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Scales this widget to fit its parent with a FittedBox.
flexible({int flex = 1, FlexFit? fit}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Wraps this widget in a Flexible inside a Row, Column or Flex.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
opacity({required double opacity, int durationInSecond = 1, Duration? duration}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Fades this widget to opacity, from 0.0 (invisible) to 1.0 (fully visible).
paddingAll(double padding) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds the same padding on all four sides of this widget.
paddingBottom(double bottom) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds bottom logical pixels of padding below this widget.
paddingDirectional({double start = 0.0, double top = 0.0, double end = 0.0, double bottom = 0.0}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Adds padding that follows the reading direction.
paddingLeft(double left) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds left logical pixels of padding to the left of this widget.
paddingOnly({double top = 0.0, double left = 0.0, double bottom = 0.0, double right = 0.0}) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds padding to any combination of sides. Sides you leave out get none.
paddingRight(double right) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds right logical pixels of padding to the right of this widget.
paddingSymmetric({double vertical = 0.0, double horizontal = 0.0}) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds vertical padding above and below, and horizontal padding on the left and right.
paddingTop(double top) → Padding

Available on Widget?, provided by the WidgetExtension extension

Adds top logical pixels of padding above this widget.
rotate({required double angle, bool transformHitTests = true, Offset? origin}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Rotates this widget by angle radians clockwise.
scale({required double scale, Offset? origin, AlignmentGeometry? alignment, bool transformHitTests = true}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Scales this widget by scale, where 1.0 is its normal size.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
tooltip({required String msg}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Shows msg in a tooltip when this widget is hovered or long-pressed.
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited
translate({required Offset offset, bool transformHitTests = true, Key? key}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Moves this widget by offset without affecting the layout around it.
validate({Widget value = const SizedBox()}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Returns this widget, or value if this widget is null.
visible(bool visible, {Widget? defaultWidget}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Shows this widget when visible is true, otherwise defaultWidget.
withHeight(double height) → SizedBox

Available on Widget?, provided by the WidgetExtension extension

Wraps this widget in a SizedBox with a fixed height.
withShaderMask(List<Color> colors, {BlendMode blendMode = BlendMode.srcATop}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Paints a left-to-right gradient of colors over this widget.
withShaderMaskGradient(Gradient gradient, {BlendMode blendMode = BlendMode.srcATop}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Paints gradient over this widget.
withSize({double width = 0.0, double height = 0.0}) → SizedBox

Available on Widget?, provided by the WidgetExtension extension

Wraps this widget in a SizedBox of the given width and height.
withTooltip({required String msg}) → Widget

Available on Widget?, provided by the WidgetExtension extension

Shows msg in a tooltip when this widget is hovered or long-pressed.
withVisibility(bool visible, {Widget? replacement, bool maintainAnimation = false, bool maintainState = false, bool maintainSize = false, bool maintainSemantics = false, bool maintainInteractivity = false}) → Visibility

Available on Widget?, provided by the WidgetExtension extension

Wraps this widget in a Visibility.
withWidth(double width) → SizedBox

Available on Widget?, provided by the WidgetExtension extension

Wraps this widget in a SizedBox with a fixed width.

Operators

operator ==(Object other) → bool
The equality operator.
inherited