Immutable layout constraints for box layout.

A size respects a BoxConstraints if, and only if, all of the following relations hold:

  • minWidth <= size.width <= maxWidth
  • minHeight <= size.height <= maxHeight

The constraints themselves must satisfy these relations:

  • 0.0 <= minWidth <= maxWidth <= double.INFINITY
  • 0.0 <= minHeight <= maxHeight <= double.INFINITY

double.INFINITY is a legal value for each constraint.

Inheritance

Static Methods

lerp(BoxConstraints a, BoxConstraints b, double t) BoxConstraints

Linearly interpolate between two BoxConstraints.

Constructors

BoxConstraints({double minWidth: 0.0, double maxWidth: double.INFINITY, double minHeight: 0.0, double maxHeight: double.INFINITY })

Creates box constraints with the given constraints.

const
BoxConstraints.expand({double width, double height })

Creates box constraints that expand to fill another box constraints.

const
BoxConstraints.loose(Size size)

Creates box constraints that forbid sizes larger than the given size.

BoxConstraints.tight(Size size)

Creates box constraints that is respected only by the given size.

BoxConstraints.tightFor({double width, double height })

Creates box constraints that require the given width or height.

const
BoxConstraints.tightForFinite({double width: double.INFINITY, double height: double.INFINITY })

Creates box constraints that require the given width or height, except if they are infinite.

const

Properties

biggest Size

The biggest size that satisifes the constraints.

read-only
flipped BoxConstraints

A box constraints with the width and height constraints flipped.

read-only
hasBoundedHeight bool

Whether there is an upper bound on the maximum height.

read-only
hasBoundedWidth bool

Whether there is an upper bound on the maximum width.

read-only
hashCode int

read-only
hasTightHeight bool

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

read-only
hasTightWidth bool

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

read-only
isNormalized bool

Returns whether the object's constraints are normalized. Constraints are normalized if the minimums are less than or equal to the corresponding maximums.

read-only
isTight bool

Whether there is exactly one size that satifies the constraints.

read-only
maxHeight double

The maximum height that satisfies the constraints.

read-only
maxWidth double

The maximum width that satisfies the constraints.

read-only
minHeight double

The minimum height that satisfies the constraints.

read-only
minWidth double

The minimum width that satisfies the constraints.

read-only
smallest Size

The smallest size that satisfies the constraints.

read-only
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator %(double value) BoxConstraints

Computes the remainder of each constraint parameter by the given value.

operator *(double factor) BoxConstraints

Scales each constraint parameter by the given factor.

operator /(double factor) BoxConstraints

Scales each constraint parameter by the inverse of the given factor.

operator ==(other) bool

The equality operator.

operator ~/(double factor) BoxConstraints

Scales each constraint parameter by the inverse of the given factor, rounded to the nearest integer.

Methods

constrain(Size size) Size

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

constrainHeight([double height = double.INFINITY ]) double

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

constrainSizeAndAttemptToPreserveAspectRatio(Size size) Size

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

constrainWidth([double width = double.INFINITY ]) double

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

copyWith({double minWidth, double maxWidth, double minHeight, double maxHeight }) BoxConstraints

Creates a copy of this box constraints but with the given fields replaced with the new values.

debugAssertIsValid({bool isAppliedConstraint: false, InformationCollector informationCollector }) bool

Asserts that the constraints are valid.

deflate(EdgeInsets edges) BoxConstraints

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

enforce(BoxConstraints constraints) BoxConstraints

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

heightConstraints() BoxConstraints

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

isSatisfiedBy(Size size) bool

Whether the given size satisfies the constraints.

loosen() BoxConstraints

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

normalize() BoxConstraints

Returns a box constraints that isNormalized.

tighten({double width, double height }) 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.

toString() String

Returns a string representation of this object.

widthConstraints() BoxConstraints

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

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited