Skip to main content

ShowDatePicker

Struct ShowDatePicker 

Source
pub struct ShowDatePicker { /* private fields */ }
Expand description

Shows a dialog containing a Material Design date picker.

The returned future resolves when the user closes the dialog. If the user cancels the dialog, it resolves with null; otherwise it resolves to the selected DateTime (inside the RouteResult).

An optional initial_date tells the picker which date to open on; with none the picker shows the input mode without a date. The first_date is the earliest allowable date and the last_date the latest. The initial_date, if given, must not be outside that range, and must satisfy the selectable_day_predicate.

The current_date represents the current day (i.e. today). This date will be highlighted in the day grid. If null, the date of calendar_delegate.now() will be used.

An optional initial_entry_mode argument can be used to display the date picker in the DatePickerEntryMode::Calendar (a calendar month grid) or DatePickerEntryMode::Input (a text input field) mode. It defaults to DatePickerEntryMode::Calendar.

An optional selectable_day_predicate function can be passed in to customize the days to enable for selection. If provided, only the days that selectable_day_predicate returns true for will be selectable.

The following optional string parameters allow you to override the default text used for various parts of the dialog: help_text, cancel_text, confirm_text, error_format_text, error_invalid_text, field_hint_text and field_label_text.

An optional locale argument can be used to set the locale for the date picker. It defaults to the ambient locale provided by Localizations.

An optional text_direction argument can be used to set the text direction (TextDirection::Ltr or TextDirection::Rtl) for the date picker. It defaults to the ambient text direction provided by Directionality.

The builder parameter can be used to wrap the dialog widget to add inherited widgets like Theme.

An optional initial_date_picker_mode argument can be used to have the calendar date picker initially appear in the DatePickerMode::Year or DatePickerMode::Day mode. It defaults to DatePickerMode::Day.

The on_date_picker_mode_change callback is called when the user toggles the entry mode.

The calendar_delegate provides the calendar the dialog works in; it defaults to the Gregorian calendar.

Dart’s anchorPoint waits for ShowDialog to take one.

Implementations§

Source§

impl ShowDatePicker

Source

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

Creates a builder for a Material date picker; Dart’s showDatePicker required arguments are the first and last dates, and every other argument is a setter.

Source

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

Which date the picker opens on; with none, it opens in the input mode without a date.

Source

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

The current day, highlighted in the day grid; defaults to the calendar delegate’s today.

Source

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

The entry mode the picker opens in. Defaults to DatePickerEntryMode::Calendar.

Source

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

Which days may be selected.

Source

pub fn help_text(self, help_text: impl Into<String>) -> ShowDatePicker

The text of the help label.

Source

pub fn cancel_text(self, cancel_text: impl Into<String>) -> ShowDatePicker

The text of the cancel button.

Source

pub fn confirm_text(self, confirm_text: impl Into<String>) -> ShowDatePicker

The text of the confirm button.

Source

pub fn locale(self, locale: Locale) -> ShowDatePicker

The locale of the date picker; defaults to the ambient locale.

Source

pub fn barrier_dismissible(self, barrier_dismissible: bool) -> ShowDatePicker

Whether tapping on the barrier dismisses the dialog. Defaults to true.

Source

pub fn barrier_color(self, barrier_color: Color) -> ShowDatePicker

The color of the modal barrier below the dialog.

Source

pub fn barrier_label(self, barrier_label: impl Into<String>) -> ShowDatePicker

The semantic label of the dialog’s modal barrier.

Source

pub fn use_root_navigator(self, use_root_navigator: bool) -> ShowDatePicker

Whether to push the dialog to the root navigator. Defaults to true.

Source

pub fn route_settings(self, route_settings: RouteSettingsRef) -> ShowDatePicker

The route settings passed to the dialog route.

Source

pub fn text_direction(self, text_direction: TextDirection) -> ShowDatePicker

The text direction of the date picker; defaults to the ambient direction.

Source

pub fn builder(self, builder: TransitionBuilder) -> ShowDatePicker

Wraps the dialog to add inherited widgets such as a theme.

Source

pub fn initial_date_picker_mode( self, initial_date_picker_mode: DatePickerMode, ) -> ShowDatePicker

The mode the calendar opens in. Defaults to DatePickerMode::Day.

Source

pub fn error_format_text( self, error_format_text: impl Into<String>, ) -> ShowDatePicker

The text of the error for an unparseable date.

Source

pub fn error_invalid_text( self, error_invalid_text: impl Into<String>, ) -> ShowDatePicker

The text of the error for an invalid date.

Source

pub fn field_hint_text( self, field_hint_text: impl Into<String>, ) -> ShowDatePicker

The hint text of the input field.

Source

pub fn field_label_text( self, field_label_text: impl Into<String>, ) -> ShowDatePicker

The label text of the input field.

Source

pub fn keyboard_type(self, keyboard_type: TextInputType) -> ShowDatePicker

The keyboard type of the input field.

Source

pub fn on_date_picker_mode_change( self, on_date_picker_mode_change: ValueChanged<DatePickerEntryMode>, ) -> ShowDatePicker

Called when the user toggles the entry mode.

Source

pub fn switch_to_input_entry_mode_icon<K>( self, switch_to_input_entry_mode_icon: impl IntoWidget<K>, ) -> ShowDatePicker

The icon that switches to the input entry mode.

Source

pub fn switch_to_calendar_entry_mode_icon<K>( self, switch_to_calendar_entry_mode_icon: impl IntoWidget<K>, ) -> ShowDatePicker

The icon that switches to the calendar entry mode.

Source

pub fn day_builder( self, day_builder: CalendarDatePickerDayBuilder, ) -> ShowDatePicker

Builds a day cell.

Source

pub fn weekday_builder( self, weekday_builder: CalendarDatePickerWeekdayBuilder, ) -> ShowDatePicker

Builds a weekday header cell.

Source

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

The calendar the dialog works in. Defaults to the Gregorian calendar.

Source

pub fn show( self, app: &mut App, context: BuildContext, ) -> CompleterFuture<RouteResult> ⓘ

Shows the dialog and returns a future that resolves when the user closes it.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ShowDatePicker

§

impl !Send for ShowDatePicker

§

impl !Sync for ShowDatePicker

§

impl !UnwindSafe for ShowDatePicker

§

impl Forget for ShowDatePicker

§

impl Freeze for ShowDatePicker
where *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 Any> is !null: Freeze, PhantomData<RcInner<dyn Any>>: Freeze, *const RcInner<dyn Page> is !null: Freeze, PhantomData<RcInner<dyn Page>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, Option<&Rc<dyn Widget>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Option<&Rc<dyn Widget>>) -> Rc<dyn Widget>>>: 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 ShowDatePicker

§

impl Unpin for ShowDatePicker
where Rc<dyn Fn(&App, DateTime) -> bool>: Unpin, *const u8 is !null: Unpin, Rc<dyn Any>: Unpin, Rc<dyn Page>: Unpin, Rc<dyn Fn(&mut App, AnyElement, Option<&Rc<dyn Widget>>) -> Rc<dyn Widget>>: Unpin, Rc<dyn Fn(&mut App, DatePickerEntryMode)>: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn Fn(&mut App, AnyElement, CalendarDatePickerDayDetails) -> Rc<dyn Widget>>: Unpin, Rc<dyn Fn(&mut App, AnyElement, CalendarDatePickerWeekdayDetails) -> Rc<dyn Widget>>: Unpin, Rc<dyn CalendarDelegate>: Unpin,

§

impl UnsafeUnpin for ShowDatePicker
where *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 Any> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Any>>: UnsafeUnpin, *const RcInner<dyn Page> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Page>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, Option<&Rc<dyn Widget>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Option<&Rc<dyn Widget>>) -> Rc<dyn Widget>>>: 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> 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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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>