@@ -5,28 +5,6 @@ import 'package:flutter/services.dart';
55import 'package:flutter_colorpicker/flutter_colorpicker.dart' ;
66import 'package:flutter_form_builder/flutter_form_builder.dart' ;
77
8- extension on Color {
9- /// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
10- /*static Color fromHex(String hexString) {
11- final buffer = StringBuffer();
12- if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
13- buffer.write(hexString.replaceFirst('#', ''));
14- return Color(int.parse(buffer.toString(), radix: 16));
15- }*/
16-
17- /// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true` ).
18- String toHex ({bool leadingHashSign = true }) {
19- /// Converts an rgba value (0-255) into a 2-digit Hex code.
20- String hexValue (int rgbaVal) {
21- assert (rgbaVal == rgbaVal & 0xFF );
22- return rgbaVal.toRadixString (16 ).padLeft (2 , '0' ).toUpperCase ();
23- }
24-
25- return '${leadingHashSign ? '#' : '' }'
26- '${hexValue (a .toInt ())}${hexValue (r .toInt ())}${hexValue (g .toInt ())}${hexValue (b .toInt ())}' ;
27- }
28- }
29-
308enum ColorPickerType { colorPicker, materialPicker, blockPicker }
319
3210/// Creates a field for `Color` input selection
@@ -176,7 +154,7 @@ class FormBuilderColorPickerFieldState
176154 FormBuilderFieldDecorationState <FormBuilderColorPickerField , Color > {
177155 late TextEditingController _effectiveController;
178156
179- String ? get valueString => value? .toHex ();
157+ String ? get valueString => value? .toHexString ();
180158
181159 Color ? _selectedColor;
182160
0 commit comments