Skip to main content

AnyBoxConstraints

Struct AnyBoxConstraints 

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

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

Rendering stores this where Flutter stores constraints that a later reader type-checks: a box’s constraints from its last AnyRenderBox::layout, read back with any_constraints, and what a LayoutBuilder hands its builder. The plain value is the one the subclass passed to super, reached by constraints or by deref, so every BoxConstraints method is available and returns a plain BoxConstraints, as an inherited method does in Dart. The subclass is recovered with extension, Dart’s is check.

Equality follows Dart’s: two plain constraints compare by value, two extended ones by value and by the subclass’s ==, and a plain value never equals an extended one. So AnyRenderBox::layout’s early return lays out again when only the extension changed.

A box’s constraints is the plain value: a render object that hands its own constraints on to its child passes the value without the extension.

Implementations§

Source§

impl AnyBoxConstraints

Source

pub const fn new(constraints: BoxConstraints) -> AnyBoxConstraints

Plain constraints.

Source

pub fn with_shared( constraints: BoxConstraints, extension: Rc<dyn BoxConstraintsExtension>, ) -> AnyBoxConstraints

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

Source

pub fn constraints(&self) -> BoxConstraints

The constraints as a layout reads them: the subclass’s super value.

Source

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

Dart’s constraints is T: the subclass instance, if these constraints are one.

Source

pub fn has_extension(&self) -> bool

Whether these constraints are a subclass instance.

Methods from Deref<Target = BoxConstraints>§

Source

pub fn min_width(self, value: f64) -> BoxConstraints

Sets min_width.

Source

pub fn max_width(self, value: f64) -> BoxConstraints

Sets max_width.

Source

pub fn min_height(self, value: f64) -> BoxConstraints

Sets min_height.

Source

pub fn max_height(self, value: f64) -> BoxConstraints

Sets max_height.

Source

pub fn copy_with(self) -> BoxConstraints

Creates a copy of this box constraints. Chain field replacements.

Source

pub fn deflate(self, edges: EdgeInsetsGeometry) -> BoxConstraints

Returns new box constraints that are smaller by the given edge dimensions.

Source

pub fn loosen(self) -> BoxConstraints

Returns new box constraints that remove the minimum width and height requirements.

Source

pub fn enforce(self, constraints: BoxConstraints) -> BoxConstraints

Returns new box constraints that respect the given constraints while being as close as possible to the original constraints.

Source

pub fn tighten(self, width: Option<f64>, height: Option<f64>) -> BoxConstraints

Returns new box constraints with a tight width and/or height as close to the given width and height as possible while still respecting the original box constraints.

Source

pub fn flipped(self) -> BoxConstraints

A box constraints with the width and height constraints flipped.

Source

pub fn width_constraints(self) -> BoxConstraints

Returns box constraints with the same width constraints but with unconstrained height.

Source

pub fn height_constraints(self) -> BoxConstraints

Returns box constraints with the same height constraints but with unconstrained width.

Source

pub fn constrain_width(self, width: f64) -> f64

Returns the width that both satisfies the constraints and is as close as possible to the given width.

Source

pub fn constrain_height(self, height: f64) -> f64

Returns the height that both satisfies the constraints and is as close as possible to the given height.

Source

pub fn constrain(self, size: Size) -> Size

Returns the size that both satisfies the constraints and is as close as possible to the given size.

Source

pub fn constrain_dimensions(self, width: f64, height: f64) -> Size

Returns the size that both satisfies the constraints and is as close as possible to the given width and height.

Source

pub fn constrain_size_and_attempt_to_preserve_aspect_ratio( self, size: Size, ) -> Size

Returns a size that attempts to meet the following conditions, in order:

  • The size must satisfy these constraints.
  • The aspect ratio of the returned size matches the aspect ratio of the given size.
  • The returned size is as big as possible while still being equal to or smaller than the given size.
Source

pub fn biggest(self) -> Size

The biggest size that satisfies the constraints.

Source

pub fn smallest(self) -> Size

The smallest size that satisfies the constraints.

Source

pub fn has_tight_width(self) -> bool

Whether there is exactly one width value that satisfies the constraints.

Source

pub fn has_tight_height(self) -> bool

Whether there is exactly one height value that satisfies the constraints.

Source

pub fn has_bounded_width(self) -> bool

Whether there is an upper bound on the maximum width.

Source

pub fn has_bounded_height(self) -> bool

Whether there is an upper bound on the maximum height.

Source

pub fn has_infinite_width(self) -> bool

Whether the width constraint is infinite.

Source

pub fn has_infinite_height(self) -> bool

Whether the height constraint is infinite.

Source

pub fn is_satisfied_by(self, size: Size) -> bool

Whether the given size satisfies the constraints.

Source

pub fn truncating_div(self, factor: f64) -> BoxConstraints

Scales each constraint parameter by the inverse of the given factor, rounded toward zero (Dart ~/).

Source

pub fn normalize(self) -> BoxConstraints

Returns a box constraints that is_normalized.

Trait Implementations§

Source§

impl Clone for AnyBoxConstraints

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 AnyBoxConstraints

A subclass prints as its BoxConstraints: neither scaffold subclass overrides toString.

Source§

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

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

impl Deref for AnyBoxConstraints

Source§

type Target = BoxConstraints

The resulting type after dereferencing.
Source§

fn deref(&self) -> &BoxConstraints

Dereferences the value.
Source§

impl From<BoxConstraints> for AnyBoxConstraints

Source§

fn from(constraints: BoxConstraints) -> AnyBoxConstraints

Converts to this type from the input type.
Source§

impl PartialEq for AnyBoxConstraints

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialEq<BoxConstraints> for AnyBoxConstraints

Source§

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

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

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

Inequality operator !=. Read more

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