color static method

ArcaneField color({
  1. String? name,
  2. String? description,
  3. IconData? icon,
  4. Color? defaultValue,
  5. required Future<Color> getter(),
  6. required Future setter(
    1. Color
    ),
  7. PromptMode mode = PromptMode.popover,
  8. Widget? dialogTitle,
  9. AlignmentGeometry? popoverAlignment,
  10. AlignmentGeometry? popoverAnchorAlignment,
  11. EdgeInsetsGeometry? popoverPadding,
  12. bool? showAlpha,
  13. bool? allowPickFromScreen,
  14. Duration writeThrottle = const Duration(seconds: 1),
})

Creates a color input field that allows users to select and set a Color value. This field uses a color picker interface, supporting popover or dialog modes for selection. It fits into the Arcane form system by providing visual color input with optional alpha channel and screen picking capabilities, often wrapped in a FieldWrapper for consistent styling.

Parameters:

  • name: Optional display name for the field.
  • description: Optional descriptive text for the field.
  • icon: Optional icon to display alongside the field.
  • defaultValue: Initial color value if none provided by the getter.
  • getter: Asynchronous function to retrieve the current color value.
  • setter: Asynchronous function to update the color value.
  • mode: Display mode for the color picker (PromptMode.popover by default).
  • dialogTitle: Custom title widget for the dialog if used.
  • popoverAlignment, popoverAnchorAlignment, popoverPadding: Positioning and padding for popover mode.
  • showAlpha: Whether to include alpha channel in the picker (default: false).
  • allowPickFromScreen: Enable screen color picking (default: false).
  • writeThrottle: Delay for write operations to prevent excessive updates (default: 1 second).

Returns: An ArcaneField<Color> configured for color input.

Implementation

static ArcaneField color({
  String? name,
  String? description,
  IconData? icon,
  Color? defaultValue,
  required Future<Color> Function() getter,
  required Future Function(Color) setter,
  PromptMode mode = PromptMode.popover,
  Widget? dialogTitle,
  AlignmentGeometry? popoverAlignment,
  AlignmentGeometry? popoverAnchorAlignment,
  EdgeInsetsGeometry? popoverPadding,
  bool? showAlpha,
  bool? allowPickFromScreen,
  Duration writeThrottle = const Duration(seconds: 1),
}) =>
    ArcaneField<Color>(
        meta: ArcaneFieldMetadata(
          name: name,
          description: description,
          icon: icon,
        ),
        provider: ArcaneFieldDirectProvider(
            defaultValue: defaultValue ?? Colors.black,
            getter: (_) => getter(),
            setter: (_, v) => setter(v)),
        builder: (context) => ArcaneColorField(
              popoverAlignment: popoverAlignment,
              popoverAnchorAlignment: popoverAnchorAlignment,
              popoverPadding: popoverPadding,
              showAlpha: showAlpha,
              allowPickFromScreen: allowPickFromScreen,
              writeThrottle: writeThrottle,
              dialogTitle: dialogTitle,
              mode: mode,
            ));