build method
Builds the widget tree for the time field, encapsulating a TimePicker within an ArcaneFieldWrapper for consistent form styling, validation, and state management.
This method retrieves the current DateTime value from the ArcaneField<DateTime> provider in the widget context, converts it to TimeOfDay for display if available, or uses the provider's default value. It constructs the TimePicker with all configured parameters (e.g., mode, use24HourFormat, showSeconds) and passes an onChanged callback that updates the provider with the selected time converted back to DateTime, or the default if cleared. The wrapper ensures the field integrates with the broader form UI, applying metadata like placeholders and error states. Returns a Widget that handles null values gracefully, making it robust for optional time inputs.
No side effects beyond provider updates; the build is pure and efficient for Flutter's declarative paradigm.
Implementation
@override
Widget build(BuildContext context) {
ArcaneField<DateTime> field = context.pylon<ArcaneField<DateTime>>();
return ArcaneFieldWrapper<DateTime>(
builder: (context) => TimePicker(
popoverAlignment: popoverAlignment,
popoverAnchorAlignment: popoverAnchorAlignment,
popoverPadding: popoverPadding,
use24HourFormat: use24HourFormat,
showSeconds: showSeconds,
dialogTitle: dialogTitle,
mode: mode,
onChanged: (v) => field.provider.setValue(field.meta.effectiveKey,
v?.toDateTime() ?? field.provider.defaultValue),
value: TimeOfDay.fromDateTime(field.provider.subject.valueOrNull ??
field.provider.defaultValue)));
}