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
impl ShowDatePicker
Sourcepub fn new(first_date: DateTime, last_date: DateTime) -> ShowDatePicker
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.
Sourcepub fn initial_date(self, initial_date: DateTime) -> ShowDatePicker
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.
Sourcepub fn current_date(self, current_date: DateTime) -> ShowDatePicker
pub fn current_date(self, current_date: DateTime) -> ShowDatePicker
The current day, highlighted in the day grid; defaults to the calendar delegate’s today.
Sourcepub fn initial_entry_mode(
self,
initial_entry_mode: DatePickerEntryMode,
) -> ShowDatePicker
pub fn initial_entry_mode( self, initial_entry_mode: DatePickerEntryMode, ) -> ShowDatePicker
The entry mode the picker opens in. Defaults to DatePickerEntryMode::Calendar.
Sourcepub fn selectable_day_predicate(
self,
selectable_day_predicate: SelectableDayPredicate,
) -> ShowDatePicker
pub fn selectable_day_predicate( self, selectable_day_predicate: SelectableDayPredicate, ) -> ShowDatePicker
Which days may be selected.
Sourcepub fn help_text(self, help_text: impl Into<String>) -> ShowDatePicker
pub fn help_text(self, help_text: impl Into<String>) -> ShowDatePicker
The text of the help label.
Sourcepub fn cancel_text(self, cancel_text: impl Into<String>) -> ShowDatePicker
pub fn cancel_text(self, cancel_text: impl Into<String>) -> ShowDatePicker
The text of the cancel button.
Sourcepub fn confirm_text(self, confirm_text: impl Into<String>) -> ShowDatePicker
pub fn confirm_text(self, confirm_text: impl Into<String>) -> ShowDatePicker
The text of the confirm button.
Sourcepub fn locale(self, locale: Locale) -> ShowDatePicker
pub fn locale(self, locale: Locale) -> ShowDatePicker
The locale of the date picker; defaults to the ambient locale.
Sourcepub fn barrier_dismissible(self, barrier_dismissible: bool) -> ShowDatePicker
pub fn barrier_dismissible(self, barrier_dismissible: bool) -> ShowDatePicker
Whether tapping on the barrier dismisses the dialog. Defaults to true.
Sourcepub fn barrier_color(self, barrier_color: Color) -> ShowDatePicker
pub fn barrier_color(self, barrier_color: Color) -> ShowDatePicker
The color of the modal barrier below the dialog.
Sourcepub fn barrier_label(self, barrier_label: impl Into<String>) -> ShowDatePicker
pub fn barrier_label(self, barrier_label: impl Into<String>) -> ShowDatePicker
The semantic label of the dialog’s modal barrier.
Whether to push the dialog to the root navigator. Defaults to true.
Sourcepub fn route_settings(self, route_settings: RouteSettingsRef) -> ShowDatePicker
pub fn route_settings(self, route_settings: RouteSettingsRef) -> ShowDatePicker
The route settings passed to the dialog route.
Sourcepub fn text_direction(self, text_direction: TextDirection) -> ShowDatePicker
pub fn text_direction(self, text_direction: TextDirection) -> ShowDatePicker
The text direction of the date picker; defaults to the ambient direction.
Sourcepub fn builder(self, builder: TransitionBuilder) -> ShowDatePicker
pub fn builder(self, builder: TransitionBuilder) -> ShowDatePicker
Wraps the dialog to add inherited widgets such as a theme.
Sourcepub fn initial_date_picker_mode(
self,
initial_date_picker_mode: DatePickerMode,
) -> ShowDatePicker
pub fn initial_date_picker_mode( self, initial_date_picker_mode: DatePickerMode, ) -> ShowDatePicker
The mode the calendar opens in. Defaults to DatePickerMode::Day.
Sourcepub fn error_format_text(
self,
error_format_text: impl Into<String>,
) -> ShowDatePicker
pub fn error_format_text( self, error_format_text: impl Into<String>, ) -> ShowDatePicker
The text of the error for an unparseable date.
Sourcepub fn error_invalid_text(
self,
error_invalid_text: impl Into<String>,
) -> ShowDatePicker
pub fn error_invalid_text( self, error_invalid_text: impl Into<String>, ) -> ShowDatePicker
The text of the error for an invalid date.
Sourcepub fn field_hint_text(
self,
field_hint_text: impl Into<String>,
) -> ShowDatePicker
pub fn field_hint_text( self, field_hint_text: impl Into<String>, ) -> ShowDatePicker
The hint text of the input field.
Sourcepub fn field_label_text(
self,
field_label_text: impl Into<String>,
) -> ShowDatePicker
pub fn field_label_text( self, field_label_text: impl Into<String>, ) -> ShowDatePicker
The label text of the input field.
Sourcepub fn keyboard_type(self, keyboard_type: TextInputType) -> ShowDatePicker
pub fn keyboard_type(self, keyboard_type: TextInputType) -> ShowDatePicker
The keyboard type of the input field.
Sourcepub fn on_date_picker_mode_change(
self,
on_date_picker_mode_change: ValueChanged<DatePickerEntryMode>,
) -> ShowDatePicker
pub fn on_date_picker_mode_change( self, on_date_picker_mode_change: ValueChanged<DatePickerEntryMode>, ) -> ShowDatePicker
Called when the user toggles the entry mode.
Sourcepub fn switch_to_input_entry_mode_icon<K>(
self,
switch_to_input_entry_mode_icon: impl IntoWidget<K>,
) -> ShowDatePicker
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.
Sourcepub fn switch_to_calendar_entry_mode_icon<K>(
self,
switch_to_calendar_entry_mode_icon: impl IntoWidget<K>,
) -> ShowDatePicker
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.
Sourcepub fn day_builder(
self,
day_builder: CalendarDatePickerDayBuilder,
) -> ShowDatePicker
pub fn day_builder( self, day_builder: CalendarDatePickerDayBuilder, ) -> ShowDatePicker
Builds a day cell.
Sourcepub fn weekday_builder(
self,
weekday_builder: CalendarDatePickerWeekdayBuilder,
) -> ShowDatePicker
pub fn weekday_builder( self, weekday_builder: CalendarDatePickerWeekdayBuilder, ) -> ShowDatePicker
Builds a weekday header cell.
Sourcepub fn calendar_delegate(
self,
calendar_delegate: Rc<dyn CalendarDelegate>,
) -> ShowDatePicker
pub fn calendar_delegate( self, calendar_delegate: Rc<dyn CalendarDelegate>, ) -> ShowDatePicker
The calendar the dialog works in. Defaults to the Gregorian calendar.
Sourcepub fn show(
self,
app: &mut App,
context: BuildContext,
) -> CompleterFuture<RouteResult> ⓘ
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.