Skip to main content

AnySize

Struct AnySize 

Source
pub struct AnySize { /* private fields */ }
Expand description

A Size that may be an instance of a Size subclass.

The framework stores this where Flutter stores a Size that a later reader type-checks: PreferredSizeWidget::preferred_size and PreferredSize’s field. The plain value is the one the subclass passed to super, reached by size or by deref; the subclass is recovered with extension, Dart’s is check.

Equality follows dart:ui’s Size.==: the values alone, so a subclass instance equals a plain size of the same width and height.

Implementations§

Source§

impl AnySize

Source

pub const fn new(size: Size) -> AnySize

A plain size.

Source

pub fn with_shared(size: Size, extension: Rc<dyn SizeExtension>) -> AnySize

A subclass instance: size is what it passed to super.

Source

pub fn size(&self) -> Size

The size as the engine sees it: the subclass’s super value.

Source

pub fn extension<T: SizeExtension>(&self) -> Option<&T>

Dart’s size is T: the subclass instance, if this size is one.

Source

pub fn has_extension(&self) -> bool

Whether this size is a subclass instance.

Methods from Deref<Target = Size>§

Source

pub fn width(&self) -> f64

The horizontal extent of this size.

Source

pub fn height(&self) -> f64

The vertical extent of this size.

Source

pub fn is_infinite(&self) -> bool

Returns true if either component is f64::INFINITY, and false if both are finite (or negative infinity, or NaN).

This is different than comparing for equality with an instance that has both components set to f64::INFINITY.

See also:

  • is_finite, which is true if both components are finite (and not NaN).
Source

pub fn is_finite(&self) -> bool

Whether both components are finite (neither infinite nor NaN).

See also:

  • is_infinite, which returns true if either component is equal to positive infinity.
Source

pub fn lt(&self, other: &Size) -> bool

Less-than operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are smaller than the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

This is a partial ordering. It is possible for two values to be neither less, nor greater than, nor equal to, another.

Source

pub fn le(&self, other: &Size) -> bool

Less-than-or-equal-to operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are smaller than or equal to the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

This is a partial ordering. It is possible for two values to be neither less, nor greater than, nor equal to, another.

Source

pub fn gt(&self, other: &Size) -> bool

Greater-than operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are bigger than the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

This is a partial ordering. It is possible for two values to be neither less, nor greater than, nor equal to, another.

Source

pub fn ge(&self, other: &Size) -> bool

Greater-than-or-equal-to operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are bigger than or equal to the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

This is a partial ordering. It is possible for two values to be neither less, nor greater than, nor equal to, another.

Source

pub fn aspect_ratio(&self) -> f64

The aspect ratio of this size.

This returns the width divided by the height.

If the width is zero, the result will be zero. If the height is zero (and the width is not), the result will be f64::INFINITY or f64::NEG_INFINITY as determined by the sign of width.

See also:

  • AspectRatio, a widget for giving a child widget a specific aspect ratio.
  • FittedBox, a widget that (in most modes) attempts to maintain a child widget’s aspect ratio while changing its size.
Source

pub fn is_empty(&self) -> bool

Whether this size encloses a zero area.

Negative areas are considered empty.

Source

pub fn truncating_div(&self, operand: f64) -> Size

Integer (truncating) division operator.

Returns a Size whose dimensions are the dimensions of this size divided by the scalar operand, rounded towards zero.

Source

pub fn shortest_side(&self) -> f64

The lesser of the magnitudes of the width and the height.

Source

pub fn longest_side(&self) -> f64

The greater of the magnitudes of the width and the height.

Source

pub fn top_left(&self, origin: Offset) -> Offset

The offset to the intersection of the top and left edges of the rectangle described by the given Offset (which is interpreted as the top-left corner) and this Size.

See also Rect::top_left.

Source

pub fn top_center(&self, origin: Offset) -> Offset

The offset to the center of the top edge of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::top_center.

Source

pub fn top_right(&self, origin: Offset) -> Offset

The offset to the intersection of the top and right edges of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::top_right.

Source

pub fn center_left(&self, origin: Offset) -> Offset

The offset to the center of the left edge of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::center_left.

Source

pub fn center(&self, origin: Offset) -> Offset

The offset to the point halfway between the left and right and the top and bottom edges of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::center.

Source

pub fn center_right(&self, origin: Offset) -> Offset

The offset to the center of the right edge of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::center_right.

Source

pub fn bottom_left(&self, origin: Offset) -> Offset

The offset to the intersection of the bottom and left edges of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::bottom_left.

Source

pub fn bottom_center(&self, origin: Offset) -> Offset

The offset to the center of the bottom edge of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::bottom_center.

Source

pub fn bottom_right(&self, origin: Offset) -> Offset

The offset to the intersection of the bottom and right edges of the rectangle described by the given offset (which is interpreted as the top-left corner) and this size.

See also Rect::bottom_right.

Source

pub fn contains(&self, offset: Offset) -> bool

Whether the point specified by the given offset (which is assumed to be relative to the top left of the size) lies between the left and right and the top and bottom edges of a rectangle of this size.

Rectangles include their top and left edges but exclude their bottom and right edges.

Source

pub fn flipped(&self) -> Size

A Size with the width and height swapped.

Trait Implementations§

Source§

impl Clone for AnySize

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 AnySize

A subclass prints as its Size: no framework subclass overrides toString.

Source§

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

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

impl Deref for AnySize

Source§

type Target = Size

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Size

Dereferences the value.
Source§

impl From<Size> for AnySize

Source§

fn from(size: Size) -> AnySize

Converts to this type from the input type.
Source§

impl PartialEq for AnySize

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialEq<Size> for AnySize

Source§

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

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for AnySize

§

impl !Send for AnySize

§

impl !Sync for AnySize

§

impl !UnwindSafe for AnySize

§

impl Forget for AnySize

§

impl Freeze for AnySize
where *const RcInner<dyn SizeExtension> is !null: Freeze, PhantomData<RcInner<dyn SizeExtension>>: Freeze,

§

impl Move for AnySize

§

impl Unpin for AnySize
where Rc<dyn SizeExtension>: Unpin,

§

impl UnsafeUnpin for AnySize
where *const RcInner<dyn SizeExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn SizeExtension>>: UnsafeUnpin,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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>