build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Renders the date field by embedding a DatePicker within ArcaneFieldWrapper<DateTime> for form integration.

This method fetches the current DateTime from the ArcaneField<DateTime> provider, applies all custom parameters (e.g., initialViewType, stateBuilder, mode), and configures the onChanged callback to update the provider with the selected date or default if cleared. It handles null values gracefully, ensuring optional field support. Returns a Widget that provides calendar interaction consistent with Arcane theming and validation; no side effects beyond provider updates; optimized for declarative builds.

Implementation

@override
Widget build(BuildContext context) {
  ArcaneField<DateTime> field = context.pylon<ArcaneField<DateTime>>();
  return ArcaneFieldWrapper<DateTime>(
      builder: (context) => DatePicker(
          initialViewType: initialViewType,
          dialogTitle: dialogTitle,
          initialView: initialView,
          popoverAlignment: popoverAlignment,
          popoverAnchorAlignment: popoverAnchorAlignment,
          popoverPadding: popoverPadding,
          stateBuilder: stateBuilder,
          mode: mode,
          onChanged: (v) => field.provider.setValue(
              field.meta.effectiveKey, v ?? field.provider.defaultValue),
          value: field.provider.subject.valueOrNull ??
              field.provider.defaultValue));
}