ColorField constructor

ColorField({
  1. required String name,
  2. Color? initialValue = defaultColor,
  3. ColorSpace initialColorSpace = ColorSpace.hex,
  4. @Deprecated('Fields should not be aware of their context') void onChanged(
    1. BuildContext context,
    2. 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,
              ),
            );
          },
        ),
      );