Skip to main content

InputDecorator

Struct InputDecorator 

Source
pub struct InputDecorator {
    pub key: Option<KeyRef>,
    pub decoration: InputDecoration,
    pub base_style: Option<TextStyle>,
    pub text_align: Option<TextAlign>,
    pub text_align_vertical: Option<TextAlignVertical>,
    pub is_focused: bool,
    pub is_hovering: bool,
    pub expands: bool,
    pub is_empty: bool,
    pub child: Option<WidgetRef>,
}
Expand description

Defines the appearance of a Material Design text field.

InputDecorator displays the visual elements of a Material Design text field around its input child. The visual elements themselves are defined by an InputDecoration object and their layout and appearance depend on the base_style, text_align, is_focused, and is_empty parameters.

TextField uses this widget to decorate its EditableText child.

InputDecorator can be used to create widgets that look and behave like a TextField but support other kinds of input.

Requires one of its ancestors to be a Material widget. The child widget, as well as the decorative widgets specified in decoration, must have non-negative baselines.

See also:

  • TextField, which uses an InputDecorator to display a border, labels, and icons, around its EditableText child.
  • Decoration and DecoratedBox, for drawing arbitrary decorations around other widgets.

Fields§

§key: Option<KeyRef>§decoration: InputDecoration

The text and styles to use when decorating the child.

Null InputDecoration properties are initialized with the corresponding values from the ambient InputDecorationThemeData.

§base_style: Option<TextStyle>

The style on which to base the label, hint, counter, and error styles if the decoration does not provide explicit styles.

If null, base_style defaults to the title_medium style from the current Theme, see ThemeData::text_theme.

The TextStyle::text_baseline of the base_style is used to determine the baseline used for text alignment.

§text_align: Option<TextAlign>

How the text in the decoration should be aligned horizontally.

§text_align_vertical: Option<TextAlignVertical>

How the text should be aligned vertically.

Determines the alignment of the baseline within the available space of the input (typically a TextField). For example, TextAlignVertical::TOP will place the baseline such that the text, and any attached decoration like prefix and suffix, is as close to the top of the input as possible without overflowing. The heights of the prefix and suffix are similarly included for other alignment values. If the height is greater than the height available, then the prefix and suffix will be allowed to overflow first before the text scrolls.

§is_focused: bool

Whether the input field has focus.

Determines the position of the label text and the color and weight of the border.

Defaults to false.

See also:

§is_hovering: bool

Whether the input field is being hovered over by a mouse pointer.

Determines the container fill color, which is a blend of InputDecoration::hover_color with InputDecoration::fill_color when true, and InputDecoration::fill_color when not.

Defaults to false.

§expands: bool

If true, the height of the input field will be as large as possible.

If wrapped in a widget that constrains its child’s height, like Expanded or SizedBox, the input field will only be affected if expands is set to true.

See TextField::min_lines and TextField::max_lines for related ways to affect the height of an input. When expands is true, both must be null in order to avoid ambiguity in determining the height.

Defaults to false.

§is_empty: bool

Whether the input field is empty.

Determines the position of the label text and whether to display the hint text.

Defaults to false.

§child: Option<WidgetRef>

The widget below this widget in the tree.

Typically an EditableText, DropdownButton, or InkWell.

Implementations§

Source§

impl InputDecorator

Source

pub fn new(decoration: InputDecoration) -> InputDecorator

Creates a widget that displays a border, labels, and icons, for a TextField.

Source

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

Dart InputDecorator(key:).

Source

pub fn base_style(self, base_style: TextStyle) -> InputDecorator

Dart InputDecorator(baseStyle:).

Source

pub fn text_align(self, text_align: TextAlign) -> InputDecorator

Dart InputDecorator(textAlign:).

Source

pub fn text_align_vertical( self, text_align_vertical: TextAlignVertical, ) -> InputDecorator

Dart InputDecorator(textAlignVertical:).

Source

pub fn is_focused(self, is_focused: bool) -> InputDecorator

Dart InputDecorator(isFocused:).

Source

pub fn is_hovering(self, is_hovering: bool) -> InputDecorator

Dart InputDecorator(isHovering:).

Source

pub fn expands(self, expands: bool) -> InputDecorator

Dart InputDecorator(expands:).

Source

pub fn is_empty(self, is_empty: bool) -> InputDecorator

Dart InputDecorator(isEmpty:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> InputDecorator

Dart InputDecorator(child:).

Source

pub fn container_of(app: &App, context: BuildContext) -> Option<AnyRenderBox>

The RenderBox that defines this decorator’s “container”. That’s the area which is filled if InputDecoration::filled is true. It’s the area adjacent to InputDecoration::icon and above the widgets that contain InputDecoration::helper_text, InputDecoration::error_text, and InputDecoration::counter_text.

TextField renders ink splashes within the container.

Trait Implementations§

Source§

impl Clone for InputDecorator

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§

impl Debug for InputDecorator

Source§

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

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

impl StatefulWidget for InputDecorator

Source§

type State = InputDecoratorState

The state this widget creates.
Source§

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

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 create_state(&self) -> InputDecoratorState

Creates the mutable state for this widget at a given location in the tree. Read more
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 InputDecorator

§

impl !Send for InputDecorator

§

impl !Sync for InputDecorator

§

impl !UnwindSafe for InputDecorator

§

impl Forget for InputDecorator

§

impl Freeze for InputDecorator
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: 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, *const u8 is !null: Freeze, PhantomData<u8>: 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,

§

impl Move for InputDecorator

§

impl Unpin for InputDecorator
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, *const u8 is !null: Unpin, Rc<Paint>: Unpin, Rc<dyn TextStyleExtension>: Unpin, Rc<dyn InputBorder>: Unpin,

§

impl UnsafeUnpin for InputDecorator

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>