Skip to main content

CalendarDatePicker

Struct CalendarDatePicker 

Source
pub struct CalendarDatePicker {
    pub key: Option<KeyRef>,
    pub initial_date: Option<DateTime>,
    pub first_date: DateTime,
    pub last_date: DateTime,
    pub current_date: Option<DateTime>,
    pub on_date_changed: ValueChanged<DateTime>,
    pub on_displayed_month_changed: Option<ValueChanged<DateTime>>,
    pub initial_calendar_mode: DatePickerMode,
    pub selectable_day_predicate: Option<SelectableDayPredicate>,
    pub day_builder: Option<CalendarDatePickerDayBuilder>,
    pub weekday_builder: Option<CalendarDatePickerWeekdayBuilder>,
    pub calendar_delegate: Rc<dyn CalendarDelegate>,
}
Expand description

A calendar date picker.

A date picker widget that lets the user select a year, month and day: the days of one month show at a time, a header button switches to a grid of years, and the arrows page between months.

The first_date and last_date bound the selectable dates (both inclusive); the selectable_day_predicate can disable single days. on_date_changed is called with the date the user picks.

Requires a Material ancestor, a MaterialLocalizations and a Directionality.

The widget takes the dates “as dates”: it reads only their day, through the calendar_delegate’s CalendarDelegate::date_only, so a time of day on initial_date is dropped (effective_initial_date and its siblings).

See also:

  • showDatePicker, which shows a dialog that contains a Material Design date picker.
  • showTimePicker, which shows a dialog that contains a Material Design time picker.

Fields§

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

The initially selected DateTime that the picker should display.

Subsequently changing this has no effect. To change the selected date, change the key to create a new instance of the widget.

If None, no date is selected.

§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.

Defaults to CalendarDelegate::now; None: not given.

§on_date_changed: ValueChanged<DateTime>

Called when the user selects a date in the picker.

§on_displayed_month_changed: Option<ValueChanged<DateTime>>

Called when the user navigates to a new month/year in the picker.

§initial_calendar_mode: DatePickerMode

The initial display of the calendar picker.

§selectable_day_predicate: Option<SelectableDayPredicate>

Function to provide full control over which dates in the calendar can be selected.

§day_builder: Option<CalendarDatePickerDayBuilder>

Builds the widget of a day in the calendar, from the default one.

§weekday_builder: Option<CalendarDatePickerWeekdayBuilder>

Builds the widget of a weekday header, from the default one.

§calendar_delegate: Rc<dyn CalendarDelegate>

The calendar system to use.

Defaults to GregorianCalendarDelegate.

Implementations§

Source§

impl CalendarDatePicker

Source

pub fn new( initial_date: Option<DateTime>, first_date: DateTime, last_date: DateTime, on_date_changed: ValueChanged<DateTime>, ) -> CalendarDatePicker

Creates a calendar date picker; Dart’s optional named arguments are the setters.

It will display a grid of days for the initial_date’s month, if non-None, or the current date’s month otherwise. The day indicated by initial_date will be selected if it is non-None.

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 effective_first_date(&self, app: &App) -> DateTime

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

Source

pub fn effective_last_date(&self, app: &App) -> DateTime

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

Source

pub fn effective_current_date(&self, app: &App) -> DateTime

Dart’s currentDate field, as its constructor fills it: the day of the date given, or of the delegate’s now.

Source

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

Dart CalendarDatePicker(key:).

Source

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

Dart CalendarDatePicker(currentDate:).

Source

pub fn on_displayed_month_changed( self, on_displayed_month_changed: ValueChanged<DateTime>, ) -> CalendarDatePicker

Dart CalendarDatePicker(onDisplayedMonthChanged:).

Source

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

Dart CalendarDatePicker(initialCalendarMode:).

Source

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

Dart CalendarDatePicker(selectableDayPredicate:).

Source

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

Dart CalendarDatePicker(dayBuilder:).

Source

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

Dart CalendarDatePicker(weekdayBuilder:).

Source

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

Dart CalendarDatePicker(calendarDelegate:).

Trait Implementations§

Source§

impl Debug for CalendarDatePicker

Source§

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

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

impl StatefulWidget for CalendarDatePicker

Source§

type State = CalendarDatePickerState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> CalendarDatePickerState

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 CalendarDatePicker

§

impl !Send for CalendarDatePicker

§

impl !Sync for CalendarDatePicker

§

impl !UnwindSafe for CalendarDatePicker

§

impl Forget for CalendarDatePicker

§

impl Freeze for CalendarDatePicker
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&mut App, DateTime)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, DateTime)>>: Freeze, *const RcInner<dyn Fn(&App, DateTime) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&App, DateTime) -> bool>>: 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 CalendarDatePicker

§

impl Unpin for CalendarDatePicker

§

impl UnsafeUnpin for CalendarDatePicker
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, DateTime)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, DateTime)>>: UnsafeUnpin, *const RcInner<dyn Fn(&App, DateTime) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&App, DateTime) -> bool>>: 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<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, 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>