ColorField constructor
ColorField({
- required String name,
- Color? initialValue = defaultColor,
- ColorSpace initialColorSpace = ColorSpace.hex,
- @Deprecated('Fields should not be aware of their context') void onChanged(
- BuildContext context,
- Color? value
Implementation
ColorField({
required super.name,
super.initialValue = defaultColor,
this.initialColorSpace = ColorSpace.hex,
@Deprecated('Fields should not be aware of their context') super.onChanged,
}) : super(
type: FieldType.color,
codec: FieldCodec(
toParam: (color) => color.value.toRadixString(16),
toValue: (param) {
if (param == null) return null;
if (param == '0') return Colors.transparent;
return Color(
int.parse(
param.length == 6 ? '00$param' : param,
radix: 16,
),
);
},
),
);