Skip to main content

ShapedInputBorder

Struct ShapedInputBorder 

Source
pub struct ShapedInputBorder {
    pub border_side: BorderSide,
    pub gap_padding: f64,
    pub shape: ShapeBorderRef,
}
Expand description

Draws a custom shape around an InputDecorator’s container.

This border allows any ShapeBorder to be used as an input decorator border. This provides maximum flexibility for custom border shapes while maintaining the gap functionality for floating labels.

When the input decorator’s label is floating, for example because its input child has the focus, the label appears in a gap in the border outline.

The input decorator’s “container” is the optionally filled area above the decorator’s helper, error, and counter.

See also:

  • OutlineInputBorder, a traditional rounded rectangle border.
  • UnderlineInputBorder, the default InputDecorator border which draws a horizontal line at the bottom of the input decorator’s container.
  • RoundedSuperellipseBorder, which can be used with this border for iOS-style shapes.
  • InputDecoration, which is used to configure an InputDecorator.

Fields§

§border_side: BorderSide

Defines the border line’s color and weight.

§gap_padding: f64

Horizontal padding on either side of the border’s InputDecoration.labelText width gap.

This value is used by the paint method to compute the actual gap width.

§shape: ShapeBorderRef

The shape of the border.

Implementations§

Source§

impl ShapedInputBorder

Source

pub fn new(shape: impl Into<ShapeBorderRef>) -> ShapedInputBorder

Creates a shaped outline border for an InputDecorator.

The shape parameter defines the custom border shape. It can be any ShapeBorder such as RoundedSuperellipseBorder, StadiumBorder, BeveledRectangleBorder, or a custom shape.

If the border_side parameter is BorderSide::NONE, it will not draw a border. However, it will still define a shape (which you can see if InputDecoration.filled is true).

If an application does not specify a border_side parameter of value BorderSide::NONE, the input decorator substitutes its own, using copy_with, based on the current theme and InputDecorator.isFocused.

See also:

  • InputDecoration.floatingLabelBehavior, which should be set to FloatingLabelBehavior.never when the border_side is BorderSide::NONE. If left as FloatingLabelBehavior.auto, the label will extend beyond the container as if the border were still being drawn.
Source

pub fn border_side(self, border_side: BorderSide) -> ShapedInputBorder

Dart ShapedInputBorder(borderSide:).

Source

pub fn gap_padding(self, gap_padding: f64) -> ShapedInputBorder

Dart ShapedInputBorder(gapPadding:).

Source

pub fn copy_with( &self, border_side: Option<BorderSide>, shape: Option<ShapeBorderRef>, gap_padding: Option<f64>, ) -> ShapedInputBorder

Creates a copy of this border with the given fields replaced.

Source

pub fn scale(&self, t: f64) -> ShapedInputBorder

Creates a copy of this border, scaled by the factor t.

Trait Implementations§

Source§

impl Clone for ShapedInputBorder

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 ShapedInputBorder

Source§

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

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

impl InputBorder for ShapedInputBorder

Source§

fn paint( &self, canvas: &mut Canvas, rect: Rect, gap_start: Option<f64>, gap_extent: f64, gap_percentage: f64, text_direction: Option<TextDirection>, )

Draw the custom shape around rect.

The border_side defines the line’s color and weight.

The top side of the border may be interrupted by a single gap if gap_extent is non-null. In that case the gap begins at gap_start - gap_padding (assuming that the text_direction is TextDirection::Ltr). The gap’s width is (gap_padding + gap_extent + gap_padding) * gap_percentage.

Source§

fn border_side(&self) -> BorderSide

Defines the border line’s color and weight. Read more
Source§

fn copy_with(&self, border_side: Option<BorderSide>) -> InputBorderRef

Creates a copy of this input border with the specified border_side.
Source§

fn is_outline(&self) -> bool

True if this border will enclose the InputDecorator’s container. Read more
Source§

fn as_widget_state_property( &self, ) -> Option<&dyn WidgetStateProperty<InputBorderRef>>

Dart’s border is WidgetStateProperty<InputBorder>: this border as the property it also is, for the borders that implement WidgetStateProperty (WidgetStateInputBorder and the deprecated MaterialState input borders).
Source§

impl PartialEq for ShapedInputBorder

Source§

fn eq(&self, other: &ShapedInputBorder) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl ShapeBorder for ShapedInputBorder

Source§

fn dimensions(&self) -> EdgeInsetsGeometry

The widths of the sides of this border represented as an EdgeInsetsGeometry.
Source§

fn scale(&self, t: f64) -> ShapeBorderRef

Creates a copy of this border, scaled by the factor t.
Source§

fn lerp_from( &self, a: Option<&dyn ShapeBorder>, t: f64, ) -> Option<ShapeBorderRef>

Linearly interpolates from another ShapeBorder (possibly of another class) to this. Read more
Source§

fn lerp_to(&self, b: Option<&dyn ShapeBorder>, t: f64) -> Option<ShapeBorderRef>

Linearly interpolates from this to another ShapeBorder (possibly of another class). Read more
Source§

fn get_inner_path( &self, rect: Rect, text_direction: Option<TextDirection>, ) -> Path

Create a Path that describes the inner edge of the border.
Source§

fn get_outer_path( &self, rect: Rect, text_direction: Option<TextDirection>, ) -> Path

Create a Path that describes the outer edge of the border.
Source§

fn paint_interior( &self, canvas: &mut Canvas, rect: Rect, paint: &Paint, text_direction: Option<TextDirection>, )

Paint a canvas with the appropriate shape. Read more
Source§

fn prefer_paint_interior(&self) -> bool

Reports whether paint_interior is implemented.
Source§

fn paint( &self, canvas: &mut Canvas, rect: Rect, text_direction: Option<TextDirection>, )

Paints the border within the given Rect on the given Canvas.
Source§

fn as_any(&self) -> &dyn Any

Downcast support for is / as in Dart.
Source§

fn eq_shape(&self, other: &dyn ShapeBorder) -> bool

Field equality. Dart’s default == is identity; subclasses that override == implement this.
Source§

fn add(&self, other: &ShapeBorderRef, reversed: bool) -> Option<ShapeBorderRef>

Attempts to create a new object that represents the amalgamation of this border and the other border. Read more
Source§

fn hit_test( &self, rect: Rect, position: Offset, text_direction: Option<TextDirection>, ) -> bool

Tests whether the outer boundary of this border contains position.
Source§

fn as_outlined_border(&self) -> Option<&(dyn OutlinedBorder + 'static)>

OutlinedBorder downcast for Dart’s is OutlinedBorder.
Source§

fn into_outlined_border(self: Rc<Self>) -> Option<Rc<dyn OutlinedBorder>>

OutlinedBorder downcast of the shared border, for Dart’s as OutlinedBorder (ShapeBorderRef::as_outlined_border_ref). An OutlinedBorder answers Some(self), as it answers as_outlined_border.
Source§

fn as_box_border(&self) -> Option<&(dyn BoxBorder + 'static)>

BoxBorder downcast for BoxBorderRef::lerp.
Source§

fn into_box_border(self: Rc<Self>) -> Option<Rc<dyn BoxBorder>>

BoxBorder downcast of the shared border (ShapeBorderRef::as_box_border_ref). A box border answers Some(self), as it answers as_box_border.

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