Skip to main content

InputDatePickerFormField

Struct InputDatePickerFormField 

Source
pub struct InputDatePickerFormField {
Show 16 fields pub key: Option<KeyRef>, pub initial_date: Option<DateTime>, pub first_date: DateTime, pub last_date: DateTime, pub on_date_submitted: Option<ValueChanged<DateTime>>, pub on_date_saved: Option<ValueChanged<DateTime>>, pub selectable_day_predicate: Option<SelectableDayPredicate>, 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 autofocus: bool, pub accept_empty_date: bool, pub focus_node: Option<FocusNodeRef>, pub calendar_delegate: Rc<dyn CalendarDelegate>,
}
Expand description

A TextFormField configured to accept and validate a date entered by a user.

When the field is saved or submitted, the text will be parsed into a DateTime according to the ambient locale’s compact date format. If the input text doesn’t parse into a date, the error_format_text message will be displayed under the field.

first_date, last_date, and selectable_day_predicate provide constraints on the dates that are valid. If the input date isn’t in the date range or doesn’t pass the given predicate, then the error_invalid_text message will be displayed under the field.

In addition to validating the user input text, this widget can accept user input through the keyboard or other input methods, via the field’s text editing; the date it shows is the initial_date, formatted.

Requires a MaterialLocalizations and a Directionality ancestor.

See also:

  • showDatePicker, which shows a dialog that contains a Material Design date picker which includes support for text entry of dates.

Fields§

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

If provided, it will be used as the default value of the field.

§first_date: DateTime

The earliest allowable DateTime that the user can input.

§last_date: DateTime

The latest allowable DateTime that the user can input.

§on_date_submitted: Option<ValueChanged<DateTime>>

An optional method to call when the user indicates they are done editing the text in the field. Will only be called if the input represents a valid DateTime.

§on_date_saved: Option<ValueChanged<DateTime>>

An optional method to call with the final date when the form is saved via FormState::save. Will only be called if the input represents a valid DateTime.

§selectable_day_predicate: Option<SelectableDayPredicate>

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

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

§autofocus: bool

Whether this field should focus itself if nothing else is already focused.

If true, the keyboard will open as soon as this input obtains focus. Otherwise, the keyboard is only shown after the user taps the text field.

Defaults to false.

§accept_empty_date: bool

Determines if an empty date would show error_format_text or not.

Defaults to false.

When autofocus is true and the date is empty, an error is not shown.

§focus_node: Option<FocusNodeRef>

Focus node of the field.

§calendar_delegate: Rc<dyn CalendarDelegate>

The calendar system to use.

Defaults to GregorianCalendarDelegate.

Implementations§

Source§

impl InputDatePickerFormField

Source

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

Creates a TextFormField configured to accept and validate a date; Dart’s optional named arguments are the setters.

If the optional initial_date is provided, then it will be used to populate the text field. If the initial_date is outside of the allowed range, it will be shown as the initial text, and an error will be shown.

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 key(self, key: KeyRef) -> InputDatePickerFormField

Dart InputDatePickerFormField(key:).

Source

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

Dart InputDatePickerFormField(initialDate:).

Source

pub fn on_date_submitted( self, on_date_submitted: ValueChanged<DateTime>, ) -> InputDatePickerFormField

Dart InputDatePickerFormField(onDateSubmitted:).

Source

pub fn on_date_saved( self, on_date_saved: ValueChanged<DateTime>, ) -> InputDatePickerFormField

Dart InputDatePickerFormField(onDateSaved:).

Source

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

Dart InputDatePickerFormField(selectableDayPredicate:).

Source

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

Dart InputDatePickerFormField(errorFormatText:).

Source

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

Dart InputDatePickerFormField(errorInvalidText:).

Source

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

Dart InputDatePickerFormField(fieldHintText:).

Source

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

Dart InputDatePickerFormField(fieldLabelText:).

Source

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

Dart InputDatePickerFormField(keyboardType:).

Source

pub fn autofocus(self, autofocus: bool) -> InputDatePickerFormField

Dart InputDatePickerFormField(autofocus:).

Source

pub fn accept_empty_date( self, accept_empty_date: bool, ) -> InputDatePickerFormField

Dart InputDatePickerFormField(acceptEmptyDate:).

Source

pub fn focus_node(self, focus_node: FocusNodeRef) -> InputDatePickerFormField

Dart InputDatePickerFormField(focusNode:).

Source

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

Dart InputDatePickerFormField(calendarDelegate:).

Trait Implementations§

Source§

impl Debug for InputDatePickerFormField

Source§

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

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

impl StatefulWidget for InputDatePickerFormField

Source§

type State = InputDatePickerFormFieldState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> InputDatePickerFormFieldState

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 InputDatePickerFormField

§

impl !Send for InputDatePickerFormField

§

impl !Sync for InputDatePickerFormField

§

impl !UnwindSafe for InputDatePickerFormField

§

impl Forget for InputDatePickerFormField

§

impl Freeze for InputDatePickerFormField
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 u8 is !null: Freeze, PhantomData<u8>: Freeze, NonZero<u32>: Freeze, &'static FocusNodeVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn CalendarDelegate> is !null: Freeze, PhantomData<RcInner<dyn CalendarDelegate>>: Freeze,

§

impl Move for InputDatePickerFormField

§

impl Unpin for InputDatePickerFormField
where Rc<dyn Key>: Unpin, Rc<dyn Fn(&mut App, DateTime)>: Unpin, Rc<dyn Fn(&App, DateTime) -> bool>: Unpin, *const u8 is !null: Unpin, NonZero<u32>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn CalendarDelegate>: Unpin,

§

impl UnsafeUnpin for InputDatePickerFormField
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 u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: 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>