Skip to main content

ShapeBorder

Enum ShapeBorder 

Source
pub enum ShapeBorder {
    RoundedRectangle {
        radius: BorderRadius,
        side: BorderSide,
    },
    Stadium {
        side: BorderSide,
    },
    Circle {
        eccentricity: f32,
        side: BorderSide,
    },
    Beveled {
        radius: BorderRadius,
        side: BorderSide,
    },
}
Expand description

What a decoration is made of — its shape, its sides, its border’s two forms, its shadows’ blur — and the shapes a border can take. What shape a box is (shape_border.dart), and the edge around it.

Copy, deliberately: this is meant to sit in a theme, and the theme’s per-widget structs are copied wholesale. A shape with a variable number of corners — the reference’s StarBorder, LinearBorder — would end that, and is not here.

Variants§

§

RoundedRectangle

Corners rounded by a radius each (rounded_rectangle_border.dart).

Fields

§radius: BorderRadius

The corner radii.

§side: BorderSide

The edge drawn around the shape.

§

Stadium

A pill: the ends are semicircles, whatever the box’s proportions (stadium_border.dart:95). What a chip is, and what a navigation indicator is.

Fields

§side: BorderSide

The edge drawn around the shape.

§

Circle

A circle inscribed in the box, or an ellipse on the way to filling it (circle_border.dart:126).

Fields

§eccentricity: f32

0.0 — a true circle, in a square taken out of the middle of the box. 1.0 — an ellipse filling the box entirely. Between them, the circle grows towards the ellipse along the box’s longer axis.

§side: BorderSide

The edge drawn around the shape.

§

Beveled

Corners cut off straight rather than rounded (beveled_rectangle_border.dart). The one shape here that is not a rounded rectangle in disguise.

Fields

§radius: BorderRadius

The corner radii, before bevelling.

§side: BorderSide

The edge drawn around the shape.

Implementations§

Source§

impl ShapeBorder

Source

pub fn rounded(radius: impl Into<BorderRadius>) -> ShapeBorder

A rectangle with these corners and no edge.

Source

pub const fn stadium() -> ShapeBorder

A pill with no edge.

Source

pub const fn circle() -> ShapeBorder

A circle with no edge.

Source

pub fn beveled(radius: impl Into<BorderRadius>) -> ShapeBorder

A rectangle with these corners cut off straight, and no edge.

Source

pub fn with_side(self, side: BorderSide) -> ShapeBorder

The same shape with an edge around it (the reference’s copyWith(side:)).

Source

pub fn side(&self) -> BorderSide

The edge around it.

Source

pub fn as_rounded(&self, rect: Rect) -> Option<(Rect, BorderRadius)>

The rounded rectangle this shape is inside rect: the box to draw and the radii to draw it with — or None when the outline is not one and wants outline.

A stadium’s radius is half its short side (stadium_border.dart:95); a circle’s box is the one _adjustRect takes out of the middle (circle_border.dart:126), with half its short side. Saying it this way is what keeps three shapes out of the path renderer.

Source

pub fn outline(&self, rect: Rect) -> Path

The outline, as a path — for every shape, including the three that did not need one.

Trait Implementations§

Source§

impl Clone for ShapeBorder

Source§

fn clone(&self) -> ShapeBorder

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 Copy for ShapeBorder

Source§

impl Debug for ShapeBorder

Source§

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

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

impl Default for ShapeBorder

Source§

fn default() -> ShapeBorder

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

impl PartialEq for ShapeBorder

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ShapeBorder

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<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> 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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

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.