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§
Methods from Deref<Target = Size>§
Sourcepub fn is_infinite(&self) -> bool
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).
Sourcepub fn is_finite(&self) -> bool
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.
Sourcepub fn lt(&self, other: &Size) -> bool
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.
Sourcepub fn le(&self, other: &Size) -> bool
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.
Sourcepub fn gt(&self, other: &Size) -> bool
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.
Sourcepub fn ge(&self, other: &Size) -> bool
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.
Sourcepub fn aspect_ratio(&self) -> f64
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.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this size encloses a zero area.
Negative areas are considered empty.
Sourcepub fn truncating_div(&self, operand: f64) -> Size
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.
Sourcepub fn shortest_side(&self) -> f64
pub fn shortest_side(&self) -> f64
Sourcepub fn longest_side(&self) -> f64
pub fn longest_side(&self) -> f64
Sourcepub fn top_left(&self, origin: Offset) -> Offset
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.
Sourcepub fn top_center(&self, origin: Offset) -> Offset
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.
Sourcepub fn top_right(&self, origin: Offset) -> Offset
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.
Sourcepub fn center_left(&self, origin: Offset) -> Offset
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.
Sourcepub fn center(&self, origin: Offset) -> Offset
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.
Sourcepub fn center_right(&self, origin: Offset) -> Offset
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.
Sourcepub fn bottom_left(&self, origin: Offset) -> Offset
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.
Sourcepub fn bottom_center(&self, origin: Offset) -> Offset
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.
Sourcepub fn bottom_right(&self, origin: Offset) -> Offset
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.
Sourcepub fn contains(&self, offset: Offset) -> bool
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.
Trait Implementations§
Source§impl Debug for AnySize
A subclass prints as its Size: no framework subclass overrides toString.
impl Debug for AnySize
A subclass prints as its Size: no framework subclass overrides toString.