Skip to main content

SearchBar

Struct SearchBar 

Source
pub struct SearchBar {
Show 31 fields pub key: Option<KeyRef>, pub controller: Option<TextEditingControllerRef>, pub focus_node: Option<FocusNodeRef>, pub hint_text: Option<String>, pub leading: Option<WidgetRef>, pub trailing: Option<Vec<WidgetRef>>, pub on_tap: Option<Listener>, pub on_tap_outside: Option<TapRegionCallback>, pub on_changed: Option<ValueChanged<String>>, pub on_submitted: Option<ValueChanged<String>>, pub constraints: Option<BoxConstraints>, pub elevation: Option<WidgetStatePropertyRef<Option<f64>>>, pub background_color: Option<WidgetStatePropertyRef<Option<Color>>>, pub shadow_color: Option<WidgetStatePropertyRef<Option<Color>>>, pub surface_tint_color: Option<WidgetStatePropertyRef<Option<Color>>>, pub overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>, pub side: Option<WidgetStatePropertyRef<Option<BorderSide>>>, pub shape: Option<WidgetStatePropertyRef<Option<OutlinedBorderRef>>>, pub padding: Option<WidgetStatePropertyRef<Option<EdgeInsetsGeometry>>>, pub text_style: Option<WidgetStatePropertyRef<Option<TextStyle>>>, pub hint_style: Option<WidgetStatePropertyRef<Option<TextStyle>>>, pub text_capitalization: Option<TextCapitalization>, pub enabled: bool, pub auto_focus: bool, pub text_input_action: Option<TextInputAction>, pub keyboard_type: Option<TextInputType>, pub scroll_padding: EdgeInsets, pub context_menu_builder: Option<EditableTextContextMenuBuilder>, pub read_only: bool, pub smart_dashes_type: Option<SmartDashesType>, pub smart_quotes_type: Option<SmartQuotesType>,
}
Expand description

A Material Design search bar.

A SearchBar looks like a TextField. Pressing the SearchBar typically shows a search view route. Users can type the search query in the search view.

See also:

  • SearchAnchor, a widget that typically shows a SearchBar and, when tapped, displays a search view.
  • SearchBarTheme, a widget that overrides the default configuration of a search bar.
  • SearchViewTheme, a widget that overrides the default configuration of a search view.

Fields§

§key: Option<KeyRef>§controller: Option<TextEditingControllerRef>

Controls the text being edited in the search bar’s text field.

§focus_node: Option<FocusNodeRef>

Defines the keyboard focus for this widget.

§hint_text: Option<String>

Text that suggests what sort of input the field accepts.

Displayed at the same location on the screen where text may be entered when the input is empty.

§leading: Option<WidgetRef>

A widget to display before the text input field.

Typically the leading widget is an Icon or an IconButton.

§trailing: Option<Vec<WidgetRef>>

A list of widgets to display in a row after the text field.

Typically these actions can represent additional modes of searching (like voice search), an avatar, or an overflow menu. There should not be more than two trailing actions.

§on_tap: Option<Listener>

Called when the user taps this search bar.

§on_tap_outside: Option<TapRegionCallback>

Called when the user taps outside the search bar’s text field.

§on_changed: Option<ValueChanged<String>>

Invoked upon user input.

§on_submitted: Option<ValueChanged<String>>

Called when the user indicates that they are done editing the text in the field.

§constraints: Option<BoxConstraints>

Optional size constraints for the search bar.

If null, the value of [SearchBarThemeData::constraints] will be used. If that is also null, then the constraints defaults to: BoxConstraints { min_width: 360.0, max_width: 800.0, min_height: 56.0, .. }.

§elevation: Option<WidgetStatePropertyRef<Option<f64>>>

The elevation of the search bar’s Material.

If null, the value of [SearchBarThemeData::elevation] will be used. If that is also null, then default value is 6.0.

§background_color: Option<WidgetStatePropertyRef<Option<Color>>>

The search bar’s background fill color.

If null, the value of [SearchBarThemeData::background_color] will be used. If that is also null, then the default value is ColorScheme::surface_container_high.

§shadow_color: Option<WidgetStatePropertyRef<Option<Color>>>

The shadow color of the search bar’s Material.

If null, the value of [SearchBarThemeData::shadow_color] will be used. If that is also null, then the default value is ColorScheme::shadow.

§surface_tint_color: Option<WidgetStatePropertyRef<Option<Color>>>

The surface tint color of the search bar’s Material.

If null, the value of [SearchBarThemeData::surface_tint_color] will be used. If that is also null, then the default value is Colors::TRANSPARENT.

§overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>

The highlight color that’s typically used to indicate that the search bar is focused, hovered, or pressed.

§side: Option<WidgetStatePropertyRef<Option<BorderSide>>>

The color and weight of the search bar’s outline.

This value is combined with shape to create a shape decorated with an outline.

§shape: Option<WidgetStatePropertyRef<Option<OutlinedBorderRef>>>

The shape of the search bar’s underlying Material.

This shape is combined with side to create a shape decorated with an outline.

§padding: Option<WidgetStatePropertyRef<Option<EdgeInsetsGeometry>>>

The padding between the search bar’s boundary and its contents.

If null, the value of [SearchBarThemeData::padding] will be used. If that is also null, then the default value is 8.0 horizontally.

§text_style: Option<WidgetStatePropertyRef<Option<TextStyle>>>

The style to use for the text being edited.

If null, defaults to the bodyLarge text style from the current Theme. The default text color is ColorScheme::on_surface.

§hint_style: Option<WidgetStatePropertyRef<Option<TextStyle>>>

The style to use for the hint_text.

If null, the value of [SearchBarThemeData::hint_style] will be used. If that is also null, the value of text_style will be used, and then bodyLarge.

§text_capitalization: Option<TextCapitalization>

Configures how the platform keyboard will select an uppercase or lowercase keyboard.

Defaults to TextCapitalization::None.

§enabled: bool

If false the text field is “disabled”: it ignores taps and its decoration is rendered in grey.

§auto_focus: bool

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

§text_input_action: Option<TextInputAction>

The type of action button to use for the keyboard.

§keyboard_type: Option<TextInputType>

The type of action button to use for the keyboard.

§scroll_padding: EdgeInsets

Configures padding to edges surrounding a Scrollable when the text field scrolls into view.

§context_menu_builder: Option<EditableTextContextMenuBuilder>

Builds the text selection toolbar when requested by the user.

See also:

§read_only: bool

Whether this text field is read only.

§smart_dashes_type: Option<SmartDashesType>

Whether to allow the platform to automatically format dashes.

§smart_quotes_type: Option<SmartQuotesType>

Whether to allow the platform to automatically format quotes.

Implementations§

Source

pub fn new() -> SearchBar

Creates a Material Design search bar.

Source

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

Dart SearchBar(key:).

Source

pub fn controller(self, controller: TextEditingControllerRef) -> SearchBar

Dart SearchBar(controller:).

Source

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

Dart SearchBar(focusNode:).

Source

pub fn hint_text(self, hint_text: impl Into<String>) -> SearchBar

Dart SearchBar(hintText:).

Source

pub fn leading<K>(self, leading: impl IntoWidget<K>) -> SearchBar

Dart SearchBar(leading:).

Source

pub fn trailing(self, trailing: Vec<WidgetRef>) -> SearchBar

Dart SearchBar(trailing:).

Source

pub fn on_tap(self, on_tap: Listener) -> SearchBar

Dart SearchBar(onTap:).

Source

pub fn on_tap_outside(self, on_tap_outside: TapRegionCallback) -> SearchBar

Dart SearchBar(onTapOutside:).

Source

pub fn on_changed( self, on_changed: impl Fn(&mut App, String) + 'static, ) -> SearchBar

Dart SearchBar(onChanged:).

Source

pub fn on_submitted( self, on_submitted: impl Fn(&mut App, String) + 'static, ) -> SearchBar

Dart SearchBar(onSubmitted:).

Source

pub fn constraints(self, constraints: BoxConstraints) -> SearchBar

Dart SearchBar(constraints:).

Source

pub fn elevation( self, elevation: WidgetStatePropertyRef<Option<f64>>, ) -> SearchBar

Dart SearchBar(elevation:).

Source

pub fn background_color( self, background_color: WidgetStatePropertyRef<Option<Color>>, ) -> SearchBar

Dart SearchBar(backgroundColor:).

Source

pub fn shadow_color( self, shadow_color: WidgetStatePropertyRef<Option<Color>>, ) -> SearchBar

Dart SearchBar(shadowColor:).

Source

pub fn surface_tint_color( self, surface_tint_color: WidgetStatePropertyRef<Option<Color>>, ) -> SearchBar

Dart SearchBar(surfaceTintColor:).

Source

pub fn overlay_color( self, overlay_color: WidgetStatePropertyRef<Option<Color>>, ) -> SearchBar

Dart SearchBar(overlayColor:).

Source

pub fn side(self, side: WidgetStatePropertyRef<Option<BorderSide>>) -> SearchBar

Dart SearchBar(side:).

Source

pub fn shape( self, shape: WidgetStatePropertyRef<Option<OutlinedBorderRef>>, ) -> SearchBar

Dart SearchBar(shape:).

Source

pub fn padding( self, padding: WidgetStatePropertyRef<Option<EdgeInsetsGeometry>>, ) -> SearchBar

Dart SearchBar(padding:).

Source

pub fn text_style( self, text_style: WidgetStatePropertyRef<Option<TextStyle>>, ) -> SearchBar

Dart SearchBar(textStyle:).

Source

pub fn hint_style( self, hint_style: WidgetStatePropertyRef<Option<TextStyle>>, ) -> SearchBar

Dart SearchBar(hintStyle:).

Source

pub fn text_capitalization( self, text_capitalization: TextCapitalization, ) -> SearchBar

Dart SearchBar(textCapitalization:).

Source

pub fn enabled(self, enabled: bool) -> SearchBar

Dart SearchBar(enabled:).

Source

pub fn auto_focus(self, auto_focus: bool) -> SearchBar

Dart SearchBar(autoFocus:).

Source

pub fn text_input_action(self, text_input_action: TextInputAction) -> SearchBar

Dart SearchBar(textInputAction:).

Source

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

Dart SearchBar(keyboardType:).

Source

pub fn scroll_padding(self, scroll_padding: EdgeInsets) -> SearchBar

Dart SearchBar(scrollPadding:).

Source

pub fn context_menu_builder( self, context_menu_builder: Option<EditableTextContextMenuBuilder>, ) -> SearchBar

Dart SearchBar(contextMenuBuilder:).

Source

pub fn read_only(self, read_only: bool) -> SearchBar

Dart SearchBar(readOnly:).

Source

pub fn smart_dashes_type(self, smart_dashes_type: SmartDashesType) -> SearchBar

Dart SearchBar(smartDashesType:).

Source

pub fn smart_quotes_type(self, smart_quotes_type: SmartQuotesType) -> SearchBar

Dart SearchBar(smartQuotesType:).

Source

pub fn default_context_menu_builder( app: &mut App, _context: BuildContext, editable_text_state: Handle<EditableTextState>, ) -> WidgetRef

Dart’s _defaultContextMenuBuilder.

Trait Implementations§

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

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

fn default() -> SearchBar

Returns the “default value” for a type. Read more
Source§

type State = SearchBarState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> SearchBarState

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§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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>