pub struct Autocomplete<T: Clone + PartialEq + Hash + Debug + 'static> {
pub key: Option<KeyRef>,
pub display_string_for_option: AutocompleteOptionToString<T>,
pub field_view_builder: AutocompleteFieldViewBuilder,
pub focus_node: Option<FocusNodeRef>,
pub on_selected: Option<AutocompleteOnSelected<T>>,
pub options_builder: AutocompleteOptionsBuilder<T>,
pub options_view_builder: Option<AutocompleteOptionsViewBuilder<T>>,
pub options_view_open_direction: OptionsViewOpenDirection,
pub options_max_height: f64,
pub text_editing_controller: Option<TextEditingControllerRef>,
pub initial_value: Option<TextEditingValue>,
}Expand description
Creates a Material-styled autocomplete widget: a text field the user enters some text in, and a list of options to choose from.
The user’s text input is received in a field built with
field_view_builder. The options to be displayed are
determined using options_builder and rendered with
options_view_builder, as RawAutocomplete does, which is
what this widget is built upon and which contains more detailed documentation.
The type parameter T represents the type of the options. Most commonly this is a
String. However, it’s also possible to use another type with a Display form, or a
custom display_string_for_option. Options will be
compared using ==.
See also:
RawAutocomplete, which is what Autocomplete is built upon, and which contains more detailed examples.
Fields§
§key: Option<KeyRef>§display_string_for_option: AutocompleteOptionToString<T>Returns the string to display in the field when the option is selected.
This is useful when using a custom T type and the string to display is different than the string to search by.
If not provided, will use the option’s Display form.
field_view_builder: AutocompleteFieldViewBuilderBuilds the field whose input is used to get the options.
Pass the provided TextEditingControllerRef to the field built here so that
RawAutocomplete can listen for changes.
If not provided, will build a standard Material-style text field by default.
focus_node: Option<FocusNodeRef>The FocusNodeRef that is used for the text field.
For more information, see RawAutocomplete::focus_node.
If this parameter is not None, then
text_editing_controller must also be non-None.
on_selected: Option<AutocompleteOnSelected<T>>Called when an option is selected by the user.
options_builder: AutocompleteOptionsBuilder<T>A function that returns the current selectable options objects given the current TextEditingValue.
options_view_builder: Option<AutocompleteOptionsViewBuilder<T>>Builds the selectable options widgets from a list of options objects.
The options are displayed floating below or above the field inside of an Overlay, not
at the same place in the widget tree as Autocomplete. To control whether it opens
upward or downward, use
options_view_open_direction.
If not provided, will build a standard Material-style list of results by default.
options_view_open_direction: OptionsViewOpenDirectionDetermines the direction in which to open the options view.
Defaults to OptionsViewOpenDirection::Down.
options_max_height: f64The maximum height used for the default Material options list widget.
When options_view_builder is None, this property sets
the maximum height that the options widget can occupy.
The default value is set to 200.
text_editing_controller: Option<TextEditingControllerRef>The TextEditingControllerRef that is used for the text field.
For more information, see RawAutocomplete::text_editing_controller.
If this parameter is not None, then focus_node must also be
non-None.
initial_value: Option<TextEditingValue>The initial value to use for the text field.
Setting the initial value does not notify
text_editing_controller’s listeners, and thus will
not cause the options UI to appear.
This parameter is ignored if text_editing_controller
is defined.
Implementations§
Source§impl<T: Clone + PartialEq + Hash + Debug + Display + 'static> Autocomplete<T>
impl<T: Clone + PartialEq + Hash + Debug + Display + 'static> Autocomplete<T>
Sourcepub fn new(
options_builder: impl Fn(&mut App, TextEditingValue) -> Task<Vec<T>> + 'static,
) -> Autocomplete<T>
pub fn new( options_builder: impl Fn(&mut App, TextEditingValue) -> Task<Vec<T>> + 'static, ) -> Autocomplete<T>
Creates an instance of Autocomplete.
display_string_for_option defaults to the option’s
Display form; an option type without one is built with
new_with_display_string.
Source§impl<T: Clone + PartialEq + Hash + Debug + 'static> Autocomplete<T>
impl<T: Clone + PartialEq + Hash + Debug + 'static> Autocomplete<T>
Sourcepub fn new_with_display_string(
options_builder: impl Fn(&mut App, TextEditingValue) -> Task<Vec<T>> + 'static,
display_string_for_option: impl Fn(&T) -> String + 'static,
) -> Autocomplete<T>
pub fn new_with_display_string( options_builder: impl Fn(&mut App, TextEditingValue) -> Task<Vec<T>> + 'static, display_string_for_option: impl Fn(&T) -> String + 'static, ) -> Autocomplete<T>
Creates an instance of Autocomplete whose options are shown as
display_string_for_option gives them, for an option type with or without a Display
form.
Sourcepub fn key(self, key: KeyRef) -> Autocomplete<T>
pub fn key(self, key: KeyRef) -> Autocomplete<T>
Dart Autocomplete(key:).
Sourcepub fn display_string_for_option(
self,
display_string_for_option: impl Fn(&T) -> String + 'static,
) -> Autocomplete<T>
pub fn display_string_for_option( self, display_string_for_option: impl Fn(&T) -> String + 'static, ) -> Autocomplete<T>
Dart Autocomplete(displayStringForOption:).
Sourcepub fn field_view_builder(
self,
field_view_builder: impl Fn(&mut App, BuildContext, TextEditingControllerRef, FocusNodeRef, VoidCallback) -> WidgetRef + 'static,
) -> Autocomplete<T>
pub fn field_view_builder( self, field_view_builder: impl Fn(&mut App, BuildContext, TextEditingControllerRef, FocusNodeRef, VoidCallback) -> WidgetRef + 'static, ) -> Autocomplete<T>
Dart Autocomplete(fieldViewBuilder:).
Sourcepub fn focus_node(self, focus_node: FocusNodeRef) -> Autocomplete<T>
pub fn focus_node(self, focus_node: FocusNodeRef) -> Autocomplete<T>
Dart Autocomplete(focusNode:).
Sourcepub fn on_selected(
self,
on_selected: impl Fn(&mut App, T) + 'static,
) -> Autocomplete<T>
pub fn on_selected( self, on_selected: impl Fn(&mut App, T) + 'static, ) -> Autocomplete<T>
Dart Autocomplete(onSelected:).
Sourcepub fn options_view_builder(
self,
options_view_builder: impl Fn(&mut App, BuildContext, AutocompleteOnSelected<T>, &[T]) -> WidgetRef + 'static,
) -> Autocomplete<T>
pub fn options_view_builder( self, options_view_builder: impl Fn(&mut App, BuildContext, AutocompleteOnSelected<T>, &[T]) -> WidgetRef + 'static, ) -> Autocomplete<T>
Dart Autocomplete(optionsViewBuilder:).
Sourcepub fn options_view_open_direction(
self,
options_view_open_direction: OptionsViewOpenDirection,
) -> Autocomplete<T>
pub fn options_view_open_direction( self, options_view_open_direction: OptionsViewOpenDirection, ) -> Autocomplete<T>
Dart Autocomplete(optionsViewOpenDirection:).
Sourcepub fn options_max_height(self, options_max_height: f64) -> Autocomplete<T>
pub fn options_max_height(self, options_max_height: f64) -> Autocomplete<T>
Dart Autocomplete(optionsMaxHeight:).
Sourcepub fn text_editing_controller(
self,
text_editing_controller: TextEditingControllerRef,
) -> Autocomplete<T>
pub fn text_editing_controller( self, text_editing_controller: TextEditingControllerRef, ) -> Autocomplete<T>
Dart Autocomplete(textEditingController:).
Sourcepub fn initial_value(self, initial_value: TextEditingValue) -> Autocomplete<T>
pub fn initial_value(self, initial_value: TextEditingValue) -> Autocomplete<T>
Dart Autocomplete(initialValue:).
Trait Implementations§
Source§impl<T: Clone + PartialEq + Hash + Debug + 'static> StatelessWidget for Autocomplete<T>
impl<T: Clone + PartialEq + Hash + Debug + 'static> StatelessWidget for Autocomplete<T>
Source§fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef
fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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)
fn debug_check_constructor(&self)
Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
this is PreferredSizeWidget: a widget that implements PreferredSizeWidget
answers with itself, which is what a parent asking an erased child for its preferred
size reads.Auto Trait Implementations§
impl<T> !RefUnwindSafe for Autocomplete<T>
impl<T> !Send for Autocomplete<T>
impl<T> !Sync for Autocomplete<T>
impl<T> !UnwindSafe for Autocomplete<T>
impl<T> Forget for Autocomplete<T>
impl<T> Freeze for Autocomplete<T>where
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn Fn(&T) -> String> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&T) -> String>>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyTextEditingController>, Retained<AnyFocusNode>, Rc<dyn Fn(&mut App)>) -> Rc<dyn Widget>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyTextEditingController>, Retained<AnyFocusNode>, Rc<dyn Fn(&mut App)>) -> Rc<dyn Widget>>>: Freeze,
NonZero<u32>: Freeze,
&'static FocusNodeVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const RcInner<dyn Fn(&mut App, T)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, T)>>: Freeze,
*const RcInner<dyn Fn(&mut App, TextEditingValue) -> Task<Vec<T>>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, TextEditingValue) -> Task<Vec<T>>>>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyElement, Rc<dyn Fn(&mut App, T)>, &[T]) -> Rc<dyn Widget>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Rc<dyn Fn(&mut App, T)>, &[T]) -> Rc<dyn Widget>>>: Freeze,
&'static TextEditingControllerVTable: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl<T> Move for Autocomplete<T>
impl<T> Unpin for Autocomplete<T>where
Rc<dyn Key>: Unpin,
Rc<dyn Fn(&T) -> String>: Unpin,
Rc<dyn Fn(&mut App, AnyElement, Retained<AnyTextEditingController>, Retained<AnyFocusNode>, Rc<dyn Fn(&mut App)>) -> Rc<dyn Widget>>: Unpin,
NonZero<u32>: Unpin,
&'static FocusNodeVTable: Unpin,
Rc<Keep>: Unpin,
Rc<dyn Fn(&mut App, T)>: Unpin,
Rc<dyn Fn(&mut App, TextEditingValue) -> Task<Vec<T>>>: Unpin,
Rc<dyn Fn(&mut App, AnyElement, Rc<dyn Fn(&mut App, T)>, &[T]) -> Rc<dyn Widget>>: Unpin,
&'static TextEditingControllerVTable: Unpin,
*const u8 is !null: Unpin,
impl<T> UnsafeUnpin for Autocomplete<T>where
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Fn(&T) -> String> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&T) -> String>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyTextEditingController>, Retained<AnyFocusNode>, Rc<dyn Fn(&mut App)>) -> Rc<dyn Widget>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyTextEditingController>, Retained<AnyFocusNode>, Rc<dyn Fn(&mut App)>) -> Rc<dyn Widget>>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static FocusNodeVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, T)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, T)>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, TextEditingValue) -> Task<Vec<T>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, TextEditingValue) -> Task<Vec<T>>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyElement, Rc<dyn Fn(&mut App, T)>, &[T]) -> Rc<dyn Widget>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Rc<dyn Fn(&mut App, T)>, &[T]) -> Rc<dyn Widget>>>: UnsafeUnpin,
&'static TextEditingControllerVTable: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.