flutter_colorpicker
flutter_colorpicker copied to clipboard
ColorPickerInput shows alpha in the last chars of the HEX color
I have a HueRingPicker in which I have enabled alpha. When the hex color is displayed the alpha channel value is shown as the last characters of the TextField, when instead alpha value should be always the first when enabled.
the current code that does it
textEditingController.text = '#' +
widget.color.red.toRadixString(16).toUpperCase().padLeft(2, '0') +
widget.color.green.toRadixString(16).toUpperCase().padLeft(2, '0') +
widget.color.blue.toRadixString(16).toUpperCase().padLeft(2, '0') +
(widget.enableAlpha ? widget.color.alpha.toRadixString(16).toUpperCase().padLeft(2, '0') : '');
The solution is easy, just move the line up
if (inputColor != widget.color.value) {
// ignore: prefer_interpolation_to_compose_strings
textEditingController.text = '#' +
(widget.enableAlpha ? widget.color.alpha.toRadixString(16).toUpperCase().padLeft(2, '0') : '') +
widget.color.red.toRadixString(16).toUpperCase().padLeft(2, '0') +
widget.color.green.toRadixString(16).toUpperCase().padLeft(2, '0') +
widget.color.blue.toRadixString(16).toUpperCase().padLeft(2, '0') ;
}