A color picker looks like a solved problem until you upgrade Flutter. Since Flutter 3.27, the old Color members (withOpacity, .red, .green, .blue, .alpha, .opacity, .value) are deprecated, and a package that still uses them fills your analyzer output with warnings you cannot fix from your own code. The README of chroma_picker counts them for flutter_colorpicker 1.1.0: on Flutter 3.35, flutter analyze reports 70 deprecated_member_use hits in its lib/.
The warnings are the visible part. The same package has older bugs that users notice: a hex field that displays #RRGGBBAA but parses #AARRGGBB, a pointer that jumps when you pick a grey, and a hue slider that looks stuck on black.
chroma_picker is a clean-room replacement. It keeps the widget names most apps already use, reads colors only through the new API, and adds keyboard and screen reader support.
What it does
Six pickers. ColorPicker is the main one: a 2D palette with a channel slider and an alpha slider. It supports 13 PaletteTypes (HSV, HSL and RGB squares plus a hue wheel), color history, labels in hex, RGB, HSV and HSL, an editable hex field, a WCAG contrast badge and an eyedropper hook. Next to it you get SlidePicker (one slider per RGB, HSV or HSL channel), HueRingPicker, MaterialPicker, BlockPicker and MultipleChoiceBlockPicker.
The modern Color API. The package reads colors only through .r, .g, .b, .a and toARGB32(). A test, test/deprecation_test.dart, runs the analyzer on lib/ and requires zero deprecated API hits. Wide-gamut colors (Display P3) are converted to sRGB before any HSV, HSL or hex math.
No drift. Every color the pickers emit is quantized to 8-bit sRGB, so the HSV to RGB round trip is idempotent. The pickers also keep their own HSVColor. That is what lets hue and saturation survive greys and black, and it means that echoing onColorChanged back into pickerColor no longer makes the pointer jump.
Hex helpers. colorFromHex and colorToHex handle #RGB, #RGBA/#ARGB, #RRGGBB, #AARRGGBB and #RRGGBBAA. The alpha position is configurable, and the parser accepts an optional # or 0x, any letter case and surrounding whitespace. Invalid input returns null.
WCAG helpers. relativeLuminance, contrastRatio, wcagRating (Fail, AA Large, AA, AAA) and useWhiteForeground. Pass contrastReference to ColorPicker and it shows the contrast badge against that color.
Accessibility. Every slider, including the hue ring, is a real Semantics slider with a label, a value and increase and decrease actions. Every control is focusable. Arrow keys, Page Up/Down, Home and End adjust sliders, and arrow keys (with Shift for bigger steps) move the palette pointer. Blocks are buttons with a selected state.
RTL and Material 3. Sliders and their arrow keys are mirrored in right-to-left layouts. Colors come from the ColorScheme: focus rings use primary and outlines use outlineVariant.
Gestures. Drags on the palette and sliders win against a parent TabBarView, PageView or scroll view. onColorChangeStart and onColorChangeEnd let you save or submit only when the user lets go.
How to use it
Add it from GitHub:
dependencies: chroma_picker: git: https://github.com/AbdeldjalilChougui/chroma_picker It requires Flutter 3.27 or later, because the Color.r/.g/.b/.a and toARGB32() API does not exist before that.
A picker in a dialog, from the README:
import 'package:flutter/material.dart'; import 'package:chroma_picker/chroma_picker.dart'; Future<Color?> pickColor(BuildContext context, Color initial) { var picked = initial; return showDialog<Color>( context: context, builder: (context) => AlertDialog( title: const Text('Pick a color'), content: SingleChildScrollView( child: StatefulBuilder( builder: (context, setState) => ColorPicker( pickerColor: picked, onColorChanged: (c) => setState(() => picked = c), hexInputBar: true, contrastReference: Colors.white, ), ), ), actions: [ TextButton( onPressed: () => Navigator.pop(context, picked), child: const Text('Done'), ), ], ), ); } The helpers work without any widget:
void helpers() { final c = colorFromHex('#3366CC80', alphaPosition: HexAlphaPosition.trailing)!; colorToHex(c, format: HexFormat.aarrggbb); // '#803366CC' colorToHex(c, format: HexFormat.rrggbbaa); // '#3366CC80' contrastRatio(const Color(0xFF767676), Colors.white); // 4.54 wcagRating(4.54); // WcagRating.aa hsvToHsl(colorToHsv(c)); // exact HSV -> HSL, keeps the hue of greys } The eyedropper is a callback. The package has no platform code, so you supply a function that returns the sampled color, or null if the user cancelled, and pass it as onEyeDropper.
Migrating from flutter_colorpicker
Most code only needs a new import:
// before import 'package:flutter_colorpicker/flutter_colorpicker.dart'; // after import 'package:chroma_picker/chroma_picker.dart'; The six widgets, the building blocks (ColorPickerArea, ColorPickerSlider, ColorPickerHueRing, ColorPickerLabel, ColorPickerInput, ColorIndicator), the enums and the helpers keep their names and main parameters. A few things changed, and the README lists each one in a table. The ones you are most likely to meet:
-
colorToHextakesformat:,includeHash:andupperCase:. The default format isHexFormat.rrggbb, with a#. -
portraitOnlyis removed fromColorPicker,HueRingPickerandMaterialPicker. There is one vertical layout, so the hex field is never disabled in landscape. -
onPrimaryChangedreceives the swatch'sMaterialColorinstead of aColor. - The painters are private. Use
ColorPickerAreaandColorPickerSlider. - To hide the label, pass
labelTypes: [].
Things to know
- The palette is not mirrored in RTL. A color space has no reading direction. Only the sliders are mirrored.
- The eyedropper is only a hook. Sampling the screen is up to your app.
- Contrast is WCAG 2.x. It uses relative luminance with the sRGB threshold 0.04045. APCA (the WCAG 3 draft) is not implemented. Translucent foregrounds are composited over the reference color, and the reference color's own alpha is ignored.
- UI strings are in English. Semantic labels and tooltips are not localized yet.
- What was tested. Each fixed issue has a test. The hex tests cover the cursor position after an edit, filtering without moving the cursor, short, lowercase and
0xinput, and#RRGGBBAA. Other tests change the color from outside and check the alpha slider, the hue slider and the hex text. The drift tests run property checks over 20,000 random colors, 1,000 chained round trips and 30 echoed palette taps.
Why I built it
The problem is in the README's list of fixed issues. The hex input wrote alpha last but parsed it first, reset its controller text on every build (which broke IME composing), and rejected pasted 0x values, whitespace and 4-digit forms. The controls did not follow external color changes. Re-deriving HSV from the echoed color reset the hue and saturation of greys and black. And the deprecation warnings stay until the package itself changes.
Patching one of these is easy. Fixing all of them means changing how the picker holds its state, so I wrote the pickers again around three rules: one color API, one internal HSVColor that is never re-derived from its own output, and one hex format that the field both shows and parses. Keeping the old names means the fix costs most apps a single import line.
Get the code
The source, the migration table, the tests and an example/ app that shows every picker with dark mode and RTL toggles are on GitHub: https://github.com/AbdeldjalilChougui/chroma_picker. It is MIT licensed.
Originally published at abdeldjalilchougui.biz.

