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
impl AnyBoxConstraints
Sourcepub const fn new(constraints: BoxConstraints) -> AnyBoxConstraints
pub const fn new(constraints: BoxConstraints) -> AnyBoxConstraints
Plain constraints.
A subclass instance: constraints is what it passed to super.
Sourcepub fn constraints(&self) -> BoxConstraints
pub fn constraints(&self) -> BoxConstraints
The constraints as a layout reads them: the subclass’s super value.
Sourcepub fn extension<T: BoxConstraintsExtension>(&self) -> Option<&T>
pub fn extension<T: BoxConstraintsExtension>(&self) -> Option<&T>
Dart’s constraints is T: the subclass instance, if these constraints are one.
Sourcepub fn has_extension(&self) -> bool
pub fn has_extension(&self) -> bool
Whether these constraints are a subclass instance.
Methods from Deref<Target = BoxConstraints>§
Sourcepub fn min_width(self, value: f64) -> BoxConstraints
pub fn min_width(self, value: f64) -> BoxConstraints
Sets min_width.
Sourcepub fn max_width(self, value: f64) -> BoxConstraints
pub fn max_width(self, value: f64) -> BoxConstraints
Sets max_width.
Sourcepub fn min_height(self, value: f64) -> BoxConstraints
pub fn min_height(self, value: f64) -> BoxConstraints
Sets min_height.
Sourcepub fn max_height(self, value: f64) -> BoxConstraints
pub fn max_height(self, value: f64) -> BoxConstraints
Sets max_height.
Sourcepub fn copy_with(self) -> BoxConstraints
pub fn copy_with(self) -> BoxConstraints
Creates a copy of this box constraints. Chain field replacements.
Sourcepub fn deflate(self, edges: EdgeInsetsGeometry) -> BoxConstraints
pub fn deflate(self, edges: EdgeInsetsGeometry) -> BoxConstraints
Returns new box constraints that are smaller by the given edge dimensions.
Sourcepub fn loosen(self) -> BoxConstraints
pub fn loosen(self) -> BoxConstraints
Returns new box constraints that remove the minimum width and height requirements.
Sourcepub fn enforce(self, constraints: BoxConstraints) -> BoxConstraints
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.
Sourcepub fn tighten(self, width: Option<f64>, height: Option<f64>) -> BoxConstraints
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.
Sourcepub fn flipped(self) -> BoxConstraints
pub fn flipped(self) -> BoxConstraints
A box constraints with the width and height constraints flipped.
Sourcepub fn width_constraints(self) -> BoxConstraints
pub fn width_constraints(self) -> BoxConstraints
Returns box constraints with the same width constraints but with unconstrained height.
Sourcepub fn height_constraints(self) -> BoxConstraints
pub fn height_constraints(self) -> BoxConstraints
Returns box constraints with the same height constraints but with unconstrained width.
Sourcepub fn constrain_width(self, width: f64) -> f64
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.
Sourcepub fn constrain_height(self, height: f64) -> f64
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.
Sourcepub fn constrain(self, size: Size) -> Size
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.
Sourcepub fn constrain_dimensions(self, width: f64, height: f64) -> Size
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.
Sourcepub fn constrain_size_and_attempt_to_preserve_aspect_ratio(
self,
size: Size,
) -> Size
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.
Sourcepub fn has_tight_width(self) -> bool
pub fn has_tight_width(self) -> bool
Whether there is exactly one width value that satisfies the constraints.
Sourcepub fn has_tight_height(self) -> bool
pub fn has_tight_height(self) -> bool
Whether there is exactly one height value that satisfies the constraints.
Sourcepub fn has_bounded_width(self) -> bool
pub fn has_bounded_width(self) -> bool
Whether there is an upper bound on the maximum width.
Sourcepub fn has_bounded_height(self) -> bool
pub fn has_bounded_height(self) -> bool
Whether there is an upper bound on the maximum height.
Sourcepub fn has_infinite_width(self) -> bool
pub fn has_infinite_width(self) -> bool
Whether the width constraint is infinite.
Sourcepub fn has_infinite_height(self) -> bool
pub fn has_infinite_height(self) -> bool
Whether the height constraint is infinite.
Sourcepub fn is_satisfied_by(self, size: Size) -> bool
pub fn is_satisfied_by(self, size: Size) -> bool
Whether the given size satisfies the constraints.
Sourcepub fn truncating_div(self, factor: f64) -> BoxConstraints
pub fn truncating_div(self, factor: f64) -> BoxConstraints
Scales each constraint parameter by the inverse of the given factor,
rounded toward zero (Dart ~/).
Sourcepub fn normalize(self) -> BoxConstraints
pub fn normalize(self) -> BoxConstraints
Returns a box constraints that is_normalized.
Trait Implementations§
Source§impl Clone for AnyBoxConstraints
impl Clone for AnyBoxConstraints
Source§impl Debug for AnyBoxConstraints
A subclass prints as its BoxConstraints: neither scaffold subclass overrides toString.
impl Debug for AnyBoxConstraints
A subclass prints as its BoxConstraints: neither scaffold subclass overrides toString.