Skip to main content

DatePickerDialog

Struct DatePickerDialog 

Source
pub struct DatePickerDialog {
Show 24 fields pub key: Option<KeyRef>, pub initial_date: Option<DateTime>, pub first_date: DateTime, pub last_date: DateTime, pub current_date: Option<DateTime>, pub initial_entry_mode: DatePickerEntryMode, pub selectable_day_predicate: Option<SelectableDayPredicate>, pub cancel_text: Option<String>, pub confirm_text: Option<String>, pub help_text: Option<String>, pub initial_calendar_mode: DatePickerMode, pub error_format_text: Option<String>, pub error_invalid_text: Option<String>, pub field_hint_text: Option<String>, pub field_label_text: Option<String>, pub keyboard_type: Option<TextInputType>, pub restoration_id: Option<String>, pub on_date_picker_mode_change: Option<ValueChanged<DatePickerEntryMode>>, pub switch_to_input_entry_mode_icon: Option<WidgetRef>, pub switch_to_calendar_entry_mode_icon: Option<WidgetRef>, pub inset_padding: EdgeInsets, pub day_builder: Option<CalendarDatePickerDayBuilder>, pub weekday_builder: Option<CalendarDatePickerWeekdayBuilder>, pub calendar_delegate: Rc<dyn CalendarDelegate>,
}
Expand description

A Material-style date picker dialog.

It displays a calendar grid of days, allowing the user to select a date, and a button to switch to a text field where a date can be typed.

It is used by ShowDatePicker, which should usually be used rather than creating a DatePickerDialog directly.

See also: CalendarDatePicker, InputDatePickerFormField, ShowDatePicker, DateRangePickerDialog.

Fields§

§key: Option<KeyRef>§initial_date: Option<DateTime>

The initially selected DateTime that the picker should display.

If this is null, there is no selected date. A date must be selected to submit the dialog.

§first_date: DateTime

The earliest allowable DateTime that the user can select.

§last_date: DateTime

The latest allowable DateTime that the user can select.

§current_date: Option<DateTime>

The DateTime representing today. It will be highlighted in the day grid. If null, the date of the calendar delegate’s now is used.

§initial_entry_mode: DatePickerEntryMode

The initial mode of date entry method for the date picker dialog.

See DatePickerEntryMode for the different data entry modes.

§selectable_day_predicate: Option<SelectableDayPredicate>

Function to provide full control over which DateTime can be selected.

§cancel_text: Option<String>

The text that is displayed on the cancel button.

§confirm_text: Option<String>

The text that is displayed on the confirm button.

§help_text: Option<String>

The text that is displayed at the top of the header.

This is used to indicate to the user what they are selecting a date for.

§initial_calendar_mode: DatePickerMode

The initial display of the calendar picker.

§error_format_text: Option<String>

The error text displayed if the entered date is not in the correct format.

§error_invalid_text: Option<String>

The error text displayed if the date is not valid.

A date is not valid if it is earlier than first_date, later than last_date, or doesn’t pass the selectable_day_predicate.

§field_hint_text: Option<String>

The hint text displayed in the TextField.

If this is null, it will default to the date format string. For example, ‘mm/dd/yyyy’ for en_US.

§field_label_text: Option<String>

The label text displayed in the TextField.

If this is null, it will default to the words representing the date format string. For example, ‘Enter Date’ for en_US.

§keyboard_type: Option<TextInputType>

The keyboard type of the TextField.

If this is null, it will default to [TextInputType::datetime].

§restoration_id: Option<String>

Restoration ID to save and restore the state of the DatePickerDialog.

If it is non-null, the date picker will persist and restore the date selected on the dialog.

The state of this widget is persisted in a RestorationBucket claimed from the surrounding RestorationScope using the provided restoration ID.

§on_date_picker_mode_change: Option<ValueChanged<DatePickerEntryMode>>§switch_to_input_entry_mode_icon: Option<WidgetRef>

An optional icon that, when pressed, switches from the calendar to the text input.

§switch_to_calendar_entry_mode_icon: Option<WidgetRef>

An optional icon that, when pressed, switches from the text input to the calendar.

§inset_padding: EdgeInsets

The padding that surrounds the dialog.

§day_builder: Option<CalendarDatePickerDayBuilder>

Called to construct the widget for a day in the calendar grid.

§weekday_builder: Option<CalendarDatePickerWeekdayBuilder>

Called to construct the widget for a weekday header.

§calendar_delegate: Rc<dyn CalendarDelegate>

The calendar the dialog works in.

Implementations§

Source§

impl DatePickerDialog

Source

pub fn new(first_date: DateTime, last_date: DateTime) -> DatePickerDialog

Creates a DatePickerDialog. Dart’s optional named arguments are the fluent setters.

The dates are kept as given; the calendar delegate truncates each to its day where the dialog reads it, as Dart’s constructor truncates them.

Source

pub fn effective_initial_date(&self, app: &App) -> Option<DateTime>

Dart’s initialDate field, as its constructor fills it: the day of the date given.

Source

pub fn key(self, key: KeyRef) -> DatePickerDialog

Dart DatePickerDialog(key:).

Source

pub fn initial_date(self, initial_date: DateTime) -> DatePickerDialog

Dart DatePickerDialog(initialDate:).

Source

pub fn current_date(self, current_date: DateTime) -> DatePickerDialog

Dart DatePickerDialog(currentDate:).

Source

pub fn initial_entry_mode( self, initial_entry_mode: DatePickerEntryMode, ) -> DatePickerDialog

Dart DatePickerDialog(initialEntryMode:).

Source

pub fn selectable_day_predicate( self, selectable_day_predicate: SelectableDayPredicate, ) -> DatePickerDialog

Dart DatePickerDialog(selectableDayPredicate:).

Source

pub fn initial_calendar_mode( self, initial_calendar_mode: DatePickerMode, ) -> DatePickerDialog

Dart DatePickerDialog(initialCalendarMode:).

Source

pub fn restoration_id( self, restoration_id: impl Into<String>, ) -> DatePickerDialog

Dart DatePickerDialog(restorationId:).

Source

pub fn inset_padding(self, inset_padding: EdgeInsets) -> DatePickerDialog

Dart DatePickerDialog(insetPadding:).

Source

pub fn calendar_delegate( self, calendar_delegate: Rc<dyn CalendarDelegate>, ) -> DatePickerDialog

Dart DatePickerDialog(calendarDelegate:).

Trait Implementations§

Source§

impl Clone for DatePickerDialog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DatePickerDialog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for DatePickerDialog

Source§

type State = DatePickerDialogState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> DatePickerDialogState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn debug_check_constructor(&self)

Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for DatePickerDialog

§

impl !Send for DatePickerDialog

§

impl !Sync for DatePickerDialog

§

impl !UnwindSafe for DatePickerDialog

§

impl Forget for DatePickerDialog

§

impl Freeze for DatePickerDialog
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&App, DateTime) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&App, DateTime) -> bool>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn(&mut App, DatePickerEntryMode)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, DatePickerEntryMode)>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerDayDetails) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerDayDetails) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerWeekdayDetails) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerWeekdayDetails) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn CalendarDelegate> is !null: Freeze, PhantomData<RcInner<dyn CalendarDelegate>>: Freeze,

§

impl Move for DatePickerDialog

§

impl Unpin for DatePickerDialog

§

impl UnsafeUnpin for DatePickerDialog
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&App, DateTime) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&App, DateTime) -> bool>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, DatePickerEntryMode)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, DatePickerEntryMode)>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerDayDetails) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerDayDetails) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerWeekdayDetails) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, CalendarDatePickerWeekdayDetails) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn CalendarDelegate> is !null: UnsafeUnpin, PhantomData<RcInner<dyn CalendarDelegate>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>