Skip to main content

DropdownButtonFormField

Struct DropdownButtonFormField 

Source
pub struct DropdownButtonFormField<T: 'static> {
    pub on_changed: Option<ValueChanged<Option<T>>>,
    pub decoration: InputDecoration,
    pub barrier_dismissible: bool,
    pub mouse_cursor: Option<MouseCursorRef>,
    pub dropdown_menu_item_mouse_cursor: Option<MouseCursorRef>,
    /* private fields */
}
Expand description

A FormField that contains a DropdownButton.

This is a convenience widget that wraps a DropdownButton widget in a FormField.

A Form ancestor is not required. The Form allows one to save, reset, or validate multiple fields at once. To use without a Form, pass a GlobalKey to the constructor and use GlobalKey::current_state to save or reset the form field.

The value parameter maps to FormField::initial_value.

See also:

  • DropdownButton, which is the underlying text field without the Form integration.

Fields§

§on_changed: Option<ValueChanged<Option<T>>>

Called when the user selects an item.

This callback is invoked after the parent Form’s Form::on_changed callback. The field’s updated value is available in the Form::on_changed callback via FormFieldState::value.

If the constructor’s enabled argument is true, the field is interactive even when on_changed is null.

§decoration: InputDecoration

The decoration to show around the dropdown button form field.

By default, draws a horizontal line under the dropdown button field but can be configured to show an icon, label, hint text, and error text.

If not specified, an InputDecorator with the focus_color set to the supplied focus_color (if any) will be used.

§barrier_dismissible: bool

Determines whether tapping outside the dropdown will close it.

Defaults to true.

§mouse_cursor: Option<MouseCursorRef>

The cursor for a mouse pointer when it enters or is hovering over the dropdown button and its DropdownMenuItems.

If this property is null, WidgetStateMouseCursor::adaptive_clickable will be used.

§dropdown_menu_item_mouse_cursor: Option<MouseCursorRef>

The cursor for a mouse pointer when it enters or is hovering over the this button’s DropdownMenuItems.

If this property is null, WidgetStateMouseCursor::adaptive_clickable will be used.

Implementations§

Source§

impl<T: Clone + PartialEq + Debug + 'static> DropdownButtonFormField<T>

Source

pub fn new( items: Option<Vec<DropdownMenuItem<T>>>, ) -> DropdownButtonFormField<T>

Creates a DropdownButton widget that is a FormField, wrapped in an InputDecorator.

The enabled argument controls whether the user can interact with the field:

  • If true, the field is interactive even if on_changed is null. The selected value is stored in the FormFieldState.
  • If false, the field is not interactive and its own autovalidate_mode is ignored, even if on_changed is non-null. FormState::validate and the parent Form’s Form::autovalidate_mode still validate it.
  • If null, the field is interactive if and only if on_changed is non-null. In either case, it is still validated. This matches the behavior before enabled was added.

The resolved FormField::enabled is true unless enabled is explicitly false.

For a description of the on_saved, validator, or autovalidate_mode parameters, see FormField. For the rest (other than decoration), see DropdownButton.

Source

pub fn key(self, key: KeyRef) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(key:).

Source

pub fn selected_item_builder( self, selected_item_builder: impl Fn(&mut App, BuildContext) -> Vec<WidgetRef> + 'static, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(selectedItemBuilder:).

Source

pub fn value(self, value: Option<T>) -> DropdownButtonFormField<T>

👎Deprecated:

Use initial_value instead.

Dart DropdownButtonFormField(value:), deprecated: use initial_value instead. This will set the initial value for the form field.

Source

pub fn initial_value( self, initial_value: Option<T>, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(initialValue:).

Source

pub fn hint<K>(self, hint: impl IntoWidget<K>) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(hint:).

Source

pub fn disabled_hint<K>( self, disabled_hint: impl IntoWidget<K>, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(disabledHint:).

Source

pub fn on_changed( self, on_changed: impl Fn(&mut App, Option<T>) + 'static, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(onChanged:).

Source

pub fn on_tap(self, on_tap: Listener) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(onTap:).

Source

pub fn elevation(self, elevation: i32) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(elevation:).

Source

pub fn style(self, style: TextStyle) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(style:).

Source

pub fn icon<K>(self, icon: impl IntoWidget<K>) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(icon:).

Source

pub fn icon_disabled_color( self, icon_disabled_color: Color, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(iconDisabledColor:).

Source

pub fn icon_enabled_color( self, icon_enabled_color: Color, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(iconEnabledColor:).

Source

pub fn icon_size(self, icon_size: f64) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(iconSize:).

Source

pub fn is_dense(self, is_dense: bool) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(isDense:).

Source

pub fn is_expanded(self, is_expanded: bool) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(isExpanded:).

Source

pub fn item_height(self, item_height: Option<f64>) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(itemHeight:).

Source

pub fn focus_color(self, focus_color: Color) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(focusColor:).

Source

pub fn focus_node(self, focus_node: FocusNodeRef) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(focusNode:).

Source

pub fn autofocus(self, autofocus: bool) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(autofocus:).

Source

pub fn dropdown_color(self, dropdown_color: Color) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(dropdownColor:).

Source

pub fn decoration( self, decoration: InputDecoration, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(decoration:).

Source

pub fn on_saved( self, on_saved: impl Fn(&mut App, Option<T>) + 'static, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(onSaved:).

Source

pub fn validator( self, validator: impl Fn(&mut App, Option<&T>) -> Option<String> + 'static, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(validator:).

Source

pub fn error_builder( self, error_builder: impl Fn(&mut App, BuildContext, String) -> WidgetRef + 'static, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(errorBuilder:).

Source

pub fn force_error_text( self, force_error_text: impl Into<String>, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(forceErrorText:).

Source

pub fn enabled(self, enabled: bool) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(enabled:).

Source

pub fn autovalidate_mode( self, autovalidate_mode: AutovalidateMode, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(autovalidateMode:).

Source

pub fn menu_max_height(self, menu_max_height: f64) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(menuMaxHeight:).

Source

pub fn enable_feedback( self, enable_feedback: bool, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(enableFeedback:).

Source

pub fn alignment( self, alignment: AlignmentGeometry, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(alignment:).

Source

pub fn border_radius( self, border_radius: BorderRadius, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(borderRadius:).

Source

pub fn padding( self, padding: impl Into<EdgeInsetsGeometry>, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(padding:).

Source

pub fn barrier_dismissible( self, barrier_dismissible: bool, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(barrierDismissible:).

Source

pub fn mouse_cursor( self, mouse_cursor: MouseCursorRef, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(mouseCursor:).

Source

pub fn dropdown_menu_item_mouse_cursor( self, dropdown_menu_item_mouse_cursor: MouseCursorRef, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(dropdownMenuItemMouseCursor:).

Source

pub fn is_vertically_expanded( self, is_vertically_expanded: bool, ) -> DropdownButtonFormField<T>

Dart DropdownButtonFormField(isVerticallyExpanded:).

Trait Implementations§

Source§

impl<T: 'static> Debug for DropdownButtonFormField<T>

Source§

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

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

impl<T: Clone + PartialEq + Debug + 'static> FormFieldLeaf for DropdownButtonFormField<T>

Source§

type Value = T

Dart’s T of FormField<T>.
Source§

fn form_field_data(&self) -> &FormFieldData<Self::Value>

Source§

impl<T: Clone + PartialEq + Debug + 'static> StatefulWidget for DropdownButtonFormField<T>

Source§

type State = DropdownButtonFormFieldState<T>

The state this widget creates.
Source§

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

Source§

fn debug_check_constructor(&self)

Source§

fn create_state(&self) -> DropdownButtonFormFieldState<T>

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 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<T> !RefUnwindSafe for DropdownButtonFormField<T>

§

impl<T> !Send for DropdownButtonFormField<T>

§

impl<T> !Sync for DropdownButtonFormField<T>

§

impl<T> !UnwindSafe for DropdownButtonFormField<T>

§

impl<T> Forget for DropdownButtonFormField<T>

§

impl<T> Freeze for DropdownButtonFormField<T>
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyFormFieldState<T>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyFormFieldState<T>) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn Fn(&mut App, Option<T>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<T>)>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn(&mut App, Option<&T>) -> Option<String>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<&T>) -> Option<String>>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, String) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, String) -> Rc<dyn Widget>>>: Freeze, T: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, PhantomData<String>: Freeze, *const RcInner<Paint> is !null: Freeze, PhantomData<RcInner<Paint>>: Freeze, PhantomData<Shadow>: Freeze, PhantomData<FontFeature>: Freeze, PhantomData<FontVariation>: Freeze, *const RcInner<dyn TextStyleExtension> is !null: Freeze, PhantomData<RcInner<dyn TextStyleExtension>>: Freeze, *const RcInner<dyn InputBorder> is !null: Freeze, PhantomData<RcInner<dyn InputBorder>>: Freeze, *const RcInner<dyn MouseCursor> is !null: Freeze, PhantomData<RcInner<dyn MouseCursor>>: Freeze, PhantomData<DropdownMenuItem<T>>: Freeze, NonZero<u32>: Freeze, *const (): Freeze, *const RcInner<dyn Fn(&mut App, AnyElement) -> Vec<Rc<dyn Widget>>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Vec<Rc<dyn Widget>>>>: Freeze, &'static FocusNodeVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze,

§

impl<T> Move for DropdownButtonFormField<T>

§

impl<T> Unpin for DropdownButtonFormField<T>
where T: Unpin, Rc<dyn Key>: Unpin, Rc<dyn Fn(&mut App, AnyFormFieldState<T>) -> Rc<dyn Widget>>: Unpin, Rc<dyn Fn(&mut App, Option<T>)>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, *const u8 is !null: Unpin, Rc<dyn Fn(&mut App, Option<&T>) -> Option<String>>: Unpin, Rc<dyn Fn(&mut App, AnyElement, String) -> Rc<dyn Widget>>: Unpin, Rc<dyn Widget>: Unpin, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, Rc<Paint>: Unpin, Rc<dyn TextStyleExtension>: Unpin, Rc<dyn InputBorder>: Unpin, Rc<dyn MouseCursor>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, Rc<dyn Fn(&mut App, AnyElement) -> Vec<Rc<dyn Widget>>>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin,

§

impl<T> UnsafeUnpin for DropdownButtonFormField<T>
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyFormFieldState<T>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyFormFieldState<T>) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<T>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<T>)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<&T>) -> Option<String>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<&T>) -> Option<String>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, String) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, String) -> Rc<dyn Widget>>>: UnsafeUnpin, T: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, &'static dyn ColorExtension: UnsafeUnpin, *const RcInner<dyn ColorExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, *const RcInner<Paint> is !null: UnsafeUnpin, PhantomData<RcInner<Paint>>: UnsafeUnpin, PhantomData<Shadow>: UnsafeUnpin, PhantomData<FontFeature>: UnsafeUnpin, PhantomData<FontVariation>: UnsafeUnpin, *const RcInner<dyn TextStyleExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn TextStyleExtension>>: UnsafeUnpin, *const RcInner<dyn InputBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn InputBorder>>: UnsafeUnpin, *const RcInner<dyn MouseCursor> is !null: UnsafeUnpin, PhantomData<RcInner<dyn MouseCursor>>: UnsafeUnpin, PhantomData<DropdownMenuItem<T>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const (): UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement) -> Vec<Rc<dyn Widget>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Vec<Rc<dyn Widget>>>>: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: 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>