ControlledTimePicker constructor

const ControlledTimePicker({
  1. Key? key,
  2. TimePickerController? controller,
  3. TimeOfDay? initialValue,
  4. ValueChanged<TimeOfDay?>? onChanged,
  5. bool enabled = true,
  6. PromptMode mode = PromptMode.dialog,
  7. Widget? placeholder,
  8. AlignmentGeometry? popoverAlignment,
  9. AlignmentGeometry? popoverAnchorAlignment,
  10. EdgeInsetsGeometry? popoverPadding,
  11. bool? use24HourFormat,
  12. bool showSeconds = false,
  13. Widget? dialogTitle,
})

Creates a ControlledTimePicker.

Either controller or initialValue should be provided to establish the initial time state. The picker can be customized with various presentation options and time format preferences.

Parameters:

  • controller (TimePickerController?, optional): External controller for programmatic control
  • initialValue (TimeOfDay?, optional): Initial time when no controller is provided
  • onChanged (ValueChanged<TimeOfDay?>?, optional): Callback for time selection changes
  • enabled (bool, default: true): Whether the picker accepts user interaction
  • mode (PromptMode, default: PromptMode.dialog): Presentation style (dialog or popover)
  • placeholder (Widget?, optional): Content displayed when no time is selected
  • popoverAlignment (AlignmentGeometry?, optional): Popover positioning relative to anchor
  • popoverAnchorAlignment (AlignmentGeometry?, optional): Anchor point on picker button
  • popoverPadding (EdgeInsetsGeometry?, optional): Internal popover content padding
  • use24HourFormat (bool?, optional): Whether to use 24-hour time format
  • showSeconds (bool, default: false): Whether to include seconds selection
  • dialogTitle (Widget?, optional): Title for dialog mode display

Example:

ControlledTimePicker(
  initialValue: TimeOfDay(hour: 14, minute: 30),
  mode: PromptMode.popover,
  use24HourFormat: true,
  onChanged: (time) => print('Selected: $time'),
);

Implementation

const ControlledTimePicker({
  super.key,
  this.controller,
  this.initialValue,
  this.onChanged,
  this.enabled = true,
  this.mode = PromptMode.dialog,
  this.placeholder,
  this.popoverAlignment,
  this.popoverAnchorAlignment,
  this.popoverPadding,
  this.use24HourFormat,
  this.showSeconds = false,
  this.dialogTitle,
});