A highly customizable Flutter color picker.
BSD-3-CLAUSE License
Bot releases are hidden (Show)
Published by rydmike over 2 years ago
NEW FEATURES
ColorPicker
properties wheelSquarePadding
and wheelSquareBorderRadius
.Published by rydmike over 2 years ago
FIX
NEW FEATURES
The order of the action buttons Cancel - OK on the bottom of the built-in
dialog can be changed to OK - Cancel. come in three flavors controlled by enum
ColorPickerActionButtonOrder
having values:
okIsRight
this is the default in order to no break past behavior.okIsLeft
adaptive
order depends on platform. Windows uses okIsLeft othersokIsRight
.The feature is enabled via the ColorPickerActionButtons
configuration
and its new property dialogActionOrder
.
By default, the picker tries to set focus to its own widgets when it is
created. It does this when either [ctrlC] or [ctrlV] are enabled in
order for the keyboard listener to be able to react to copy-paste events
even if no control on the widget has been focused yet.
If you need another widget to retain focus, e.g., if the picker is used on a
surface/scope shared with other widgets and not in its own dialog, then
setting [autoFocus] to false might help.
If both [ctrlC] and [ctrlV] are false, the picker yields the focus the
same way as setting [autoFocus] false, but then you have no keyboard shortcut
copy-paste functions at all. With [autoFocus] false, you can still use
keyboard copy-paste shortcuts and yield the focus from the picker.
When you do this, the copy-paste keyboard shortcuts will not work until
one of the pickers components have been focused by interacting with them.
The picker still grabs focus when you click on its background, as one way
to set focus to keyboard listener to enable copy-paste keyboard shortcuts
or when you operate any of its controls, the control in question
always gains focus.
You can now turn OFF the autofocus used by the keyboard listener by setting
autoFocus
to false in ColorPickerCopyPasteBehavior
.
This new feature can potentially also be used to address issue #33.
UPDATED
The generated Material Color swatch you get when you click on any color in the
wheel picker has been updated and is a bit improved. It is still not the
actual M2 MaterialColor
swatch algorithm, like the Tonal Palette is when it
comes to Material 3. Which is using the actual seed algorithm for the primary
tonal palette you get with the selected color as input. The wheel does detect when
you have selected any Material 2 swatch color and shows its swatch then.
For other colors, it computes a MaterialColor
swatch. This swatch
is still not using the correct algorithm, but it is a bit better looking
than before.
There is currently no know Dart implementation of this algorithm, if there
were it would be in use here. There are some versions in JS of the algorithm
that have been reverse engineered from the Material 2 design guide website.
If someone wants to make a Dart version, that would be fabulous. Links and more
information can be found in ColorTools.createPrimarySwatch
WED DEMO
The web demo app has been updated to demonstrate above new features.
Published by rydmike over 2 years ago
FIX
IconButton
between Flutter version 2.10.0 and earlier versions, e.g. 2.8.1, where iconSize
is nullable in Flutter 2.10.x, but not e.g. in Flutter 2.8.1. See issue report #40 and PR #41.Published by rydmike over 2 years ago
NEW FEATURE
Added capability to show a Material 3 tonal palette as per
Material 3 design specification.
To enable it set new ColorPicker
property enableTonalPalette
to true. It is false by default. Like the Material Swatch shades heading that
that has an optional subHeading
widget, when tonal palette is enabled you can show an optional tonalSubheading
widget above it.
When you click/select a color in the color picker and tonal palette is enabled, a 13 shade Material 3 tonal palette for the selected color will be generated, always starting with black, tone 0 for the used seed color and ending in white, tone 100.
The official Material 3 Dart library is used to create the tonal palette from any selected color. The color you select functions a seed color to
generate the tonal palette and might not itself be included and selected in the palette. You can of course click on any color in the generated palette to select and pick a color.
Selecting a color in the tonal palette, only selects the color in the palette, it does not update the palette. Only when you select a color from the other color sources in the picker, is that color used as key, to seed and generate an updated color palette for the selected color.
UPDATED
The WEB example was updated to include enabling and disabling the tonal palette and built it with Flutter version, stable 2.10.1.
All dependencies in the Web demo were updated to their latest released version.
The Web demo example requires at least Flutter 2.10.0 to be built, it uses ColorScheme properties in its theme that were not available earlier and removed in 2.10.0 deprecated color properties from its theme. The color picker package itself, still has unchanged version requirement of Dart SDK sdk: '>=2.14.0 <3.0.0'.
Published by rydmike almost 3 years ago
Published by rydmike over 3 years ago
RepaintBoundary
widgets aroundPublished by rydmike over 3 years ago
Fix: The useRootNavigator
argument is now respected on all Navigator
pop
functions used in the ColorPicker
widget itself and by
built-in dialogs used by the ColorPicker
. In order to support this,
the current useRootNavigator
property in the ColorPicker.showPickerDialog()
and
in the function showColorPickerDialog
had to be deprecated.
The property has moved to become a configuration option in ColorPickerActionButtons
class in order to make it accessible to the Navigator pop functions both in
the ColorPicker
widget itself, as well as to built-in dialogs.
The default behavior has not changed, the setting still defaults to using
dialogs that use the root navigator, but now the pop functions work as intended.
If you for some reason have used none root navigators for the built-in
dialogs in previous versions, you need to set
ColorPickerActionButtons(useRootNavigator: false)
and pass it to
ColorPicker(actionButtons)
or showColorPickerDialog(actionButtons)
.
Tests: Started adding more tests and coverage report.
Total 5668 tests, coverage 65.36%.
Documentation and typo updates.
Published by rydmike over 3 years ago
swatchContainsColor
.secondaryOnDesktopLongOnDeviceAndWeb
to true
(defaults to false) inenableOpacity
feature is used.Published by rydmike over 3 years ago
New feature: Enabled updating the color picker externally. Just set the color
property of the widget to a
new value to update it. You can even "remote control" the color picker by updating the color
, if so needed.
This is mostly a potential use-case for desktop/web when the picker is not used in a dialog.
You can of course use this on a phone or tablet too, but often there is not room enough to keep the picker
visible on the main surface this way on mobile devices. However, on desktops it is certainly a valid use
case that should be supported. It was previously not supported by design, but as we are going for covering
web/desktop use-cases, it should certainly be supported. This update adds support for it. The picker only
updates if the externally provided color
constructor property differs from its internally kept color
state. Finding the right picker, computing its swatches, is a bit demanding, but it seems to work fluidly,
even when remote controlling the wheel and sliders interactively.
Web example: Updated the Web example to also show the "remote control" of the on-screen color picker. A
remote control widget with a few color boxes, that you can click on to update its colors externally was added.
The demo even goes meta! You can use a modal dialog version of the ColorPicker, to control the ColorPicker
on the screen in the card, from the dialog ColorPicker! Maybe not as such so useful, but an interesting demo.
Published by rydmike over 3 years ago
This release only contains documentation updates from pre-release 2.0.0-nullsafety.5
Thi is the first stable release of the null-safe version
This is a MAJOR new feature release, in addition to the null-safety conversion.
Please see changelogs from 2.0.0-nullsafety.0 to nullsafety.5, for a complete list of changes and new features.
To get familiar with version 2.0.0 and all its new features, it is recommended to go through the updated tutorial,
and the API guide in the readme file.
For convenience, the list of breaking changes from last stable version 1.1.5 are listed below.
In addition to breaking changes as a result of the null-safety implementation, this release contain a few other
minor breaking changes from version 1.x, they mostly concern visual nuances and label defaults.
The colorCodeIcon
has been deprecated and no longer has any function. To modify the copy icon on the color
code entry field, define the ColorPickerCopyPasteBehavior(copyIcon: myIcon)
and provide it to the
copyPasteBehavior
property, it defaults to same icon as in versions 1.x.
The bottom dialog action button that selects the color now says OK instead of Select. The label for the OK
button by default comes from a Material localization. You can as before change it to whatever string you want.
The dialog bottom action button for OK by default now uses a plain TextButton
and
not an OutlinedButton
. This change is done to conform to a less opinionated default style. You can still
manually configure it to use an OutlinedButton
instead as before. Now you can choose, before there was
no choice.
The dialog bottom OK button is no longer auto-focused.
The extension FlexPickerNoNullStringExtensions
on none nullable
String
named toColor
, no longer returns color value Color(0x00000000)
for colors that cannot be parsed
to a Color. It now returns Color(0xFF000000)
. This is because the Flutter SDK dislikes the fully transparent
black Color(0x00000000)
, if it is full opaque black, it works better as a fallback safety color.
The FlexPickerNullableStringExtensions
on String?
named toColorMaybeNull
works as before by returning
null when the String?
cannot be parsed to a Color
.
The color code edit and entry field now works more like a normal text entry field. It still
only accepts valid hex input and converts all input to uppercase.
Published by rydmike over 3 years ago
borderColor
did not change the border color on the wheel when wheelHasBorder
was true.showPickerDialog
method now exposes most (= not directly controlled) propertiesAlertDialog
used to make the dialog, this includes e.g. the backgroundColor
, elevation
,clipBehavior
and shape
as new exposed properties that may be useful.showColorPickerDialog
that returns aFuture<Color>
which when the dialog is closed, returns the selected color from the dialog or original startColorPicker
showPickerDialog
method, except all the onChanged callbacks that are excluded.elevation
and title
in the showPickerDialog
method, would collide with the sameColorPicker
. The dialog's elevation and title in the showColorPickerDialog
aredailogElevation
and dialogTitle
in it.showColorPickerDialog
function.Published by rydmike over 3 years ago
enableOpacity
property was added that enables an opacityopacityTrackHeight
, the width with opacityTrackWidth
and theopacityThumbRadius
. There is also a opacitySubheading
Widget that canNOTE:
This is FlexColorPicker 2.0.0 dev and pre-release with sound null safety. It contains
many new features compared to previous stable 1.1.5 none null safe version.The package documentation has not yet been updated to cover the new features that are
being introduced in final 2.0.0 version together with null-safety. The changelog covers
the major changes. The API-documentation is up to date as well. The bundled and live
web demo app demonstrates all the new features, and you
can change most API settings. The demo also shows each API name and current value in a tooltip for
each control that modifies API values in the demo.No more new features will be added to 2.0.0 before the pending stable release. This release is
a stabilization and fine-tuning phase. The remaining minimum requirements for releasing stable version 2
is an update of this package documentation to cover all new features.
Later releases will provide additional refinements, further testing and CI/CD pipe.
Published by rydmike over 3 years ago
editUsesParsedPaste
now works as intended, if true, desktop keyboard paste commands,editUsesParsedPaste
false (default).colorCodeHasColor
is true, then the background of the color code entry field uses the currentcolorCodeReadOnly
the color code entry field is always read only. Normally color code cancopyPasteBehavior
property received three new features and properties:
secondaryMenu
to true.secondaryOnDesktopLongOnDevice
to true.parseShortHexCode
is true the hex color code paste action and field entry parser,FlexPickerNoNullStringExtensions
on String
got a newColor toColorShort(bool enableShortRGB)
.FlexPickerNullableStringExtensions
on String?
got a newColor? toColorShortMaybeNull(bool enableShortRGB)
.FlexPickerNoNullStringExtensions
on none nullableString
named toColor
no longer returns color value Color(0x00000000)
for colors that cannot be parsedColor(0xFF000000)
. This is because the Flutter SDK dislikes the fully transparentColor(0x00000000)
, if it is full opaque black, it works better as a fallback safety color.FlexPickerNullableStringExtensions
on String?
named toColorMaybeNull
works as before by returningString?
cannot be parsed to a Color
.ColorPickerActionButtonType
and ColorPickerCopyPasteBehavior
.See API documentation for more information.
Published by rydmike over 3 years ago
Documentation and live Web demo link fixes.
Published by rydmike over 3 years ago
There are many new features included in this version 2 pre-release. The new features can be explored with
live Web example. Its source code is also included in the package
example folder, in "example/lib/demo/main.dart".
Improvements: The wheel picker now move on pointer down to point location, it no longer requires a slight movement
for its thumbs to move to the selected start tracking point.
Improvements: Keyboard traversal of the colors and selecting indicator colors with the keyboard via
enter or space. The wheel can however still not be operated with a keyboard, only touch and mouse controlled.
New property onColorChangeStart
: Called when user starts color selection with current color before the change.
New property onColorChangeEnd
: Called when user ends color selection with the new color value.
New property selectedPickerTypeColor
: The color of the thumb on the slider that shows the selected picker.
Ported from none null-safe version 1.1.4, does not exist in version 2.0.0-nullsafety.0.
New property colorCodePrefixStyle
: Defines the text style of the prefix for the color code.
If not defined it defaults to same style as colorCodeTextStyle
.
Ported from none null-safe version 1.1.4, does not exist in version 2.0.0-nullsafety.0.
New property title
: A Widget used as an app bar type of title widget above the heading. Can
include copy, paste, select-close and cancel-cancel icon buttons when picker is used as a dialog.
Major new feature: An actionButtons
property that takes an ColorPickerActionButtons()
. Used to define
what type of Ok and Cancel action buttons the color picker has when used in a dialog.
It is possible to define if
bottom action buttons should be TextButton
, OutlinedButton
or ElevatedButton
per button.
If not defined, the labels on the buttons come from Material localizations, not from default hard coded values.
See breaking label for the 'Select' label. There are optional select/OK and cancel icon buttons that can be used
in the title bar for a more compact dialog. See API documentation for more information.
Major feature: A copyPasteBehavior
property that takes an ColorPickerCopyPasteBehavior()
.
Used to define the copy/paste behavior of the color picker, including:
All copy/paste behaviors are optional and can be enabled based on what is needed.
For the copy format, the desired resulting RGB color string format can be configured to use #RRGGBB
RRGGBB #AARRGGBB AARRGGBB and 0xAARRGGBB (default) options. The selected copy format is indicated with the
corresponding prefix in the color code display/edit field when it is enabled.
Paste supports parsing multiple RGB color string formats. It automatically detects what format is used and auto
parses to correct Flutter/Dart color value. You can e.g. paste string formatted as #RRGGBB RRGGBB #AARRGGBB
AARRGGBB #RGB RGB or 0xAARRGGBB, partial color string values also work. You can also activate
a snack bar that informs the users if they paste color strings in an unsupported RGB string format into the
color picker.
See API documentation for more information.
Major new feature: The picker can display recently used colors in a list of color indicators at the bottom of
the picker. You can use the following properties to control it.
showRecentColors
: Set to true/false to enable/disable the usage of the recent colors feature.
recentColorsSubheading
: Subheading widget for the recently used colors. Typically, a Text widget,
e.g. Text('Recent colors'). If not provided there is no sub heading for the recently used colors.
maxRecentColors
: Number of recent colors to track, from 2 to 20 allowed.
recentColors
: a list with current recent color, defaults to empty. You can store the last list
and use it to restore the previous recent colors list.
onRecentColorsChanged
: Optional value callback that returns a copy the current list of recently
used colors. Use it store a copy of the recent colors in order to be able to restore it later.
See API documentation for more information.
The following are minor breaking changes from version 1.x, they mostly concern visual nuances and label defaults.
colorCodeIcon
has been deprecated and no longer has any function. To modify the copy icon on the colorColorPickerCopyPasteBehavior(copyIcon: myIcon)
and provide it to thecopyPasteBehavior
property, it defaults to same icon as in version 1.x.TextButton
andOutlinedButton
, this change is done to conform to a less opinionated default style. You can stillOutlinedButton
instead as before. Now you can choose, before there wasPublished by rydmike over 3 years ago
selectedPickerTypeColor
: When color was undefined, the thumb did not receive the same text color as theselectedPickerTypeColor
is undefined.Published by rydmike over 3 years ago
selectedPickerTypeColor
: Defines the color of the thumb on the slider that shows the selected picker.colorCodePrefixStyle
: Defines the text style of the prefix for the color code.colorCodeTextStyle
.Published by rydmike over 3 years ago
Published by rydmike almost 4 years ago
EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0)
, as it should have been.Published by rydmike almost 4 years ago
TextStyle
via property colorCodeTextStyle
was not also applied to the shown color integer value when showColorValue
was set to true
, as stated in API doc and intended.