BoxConstraints class
Immutable layout constraints with min/max width and height.
Follows Flutter's BoxConstraints API: BoxConstraints.tight, BoxConstraints.loose, BoxConstraints.expand, BoxConstraints.tightFor. Use deflate to subtract padding, enforce to clamp to another constraint.
- Inheritance
-
- Object
- Constraints
- BoxConstraints
Constructors
- BoxConstraints({int minWidth = 0, int maxWidth = Constraints.infinity, int minHeight = 0, int maxHeight = Constraints.infinity})
-
Creates BoxConstraints with the given min/max width and height.
const
- BoxConstraints.expand({int? width, int? height})
-
Creates constraints that force expansion to fill available space.
const
- BoxConstraints.loose(Size size)
-
Creates loose constraints that allow sizes from zero up to the given
size. - BoxConstraints.tight(Size size)
-
Creates tight constraints that force the given exact
size. - BoxConstraints.tightFor({int? width, int? height})
-
Creates constraints that are tight for the given dimensions.
const
Properties
- asBoxConstraints → BoxConstraints
-
Returns this as BoxConstraints, or throws if it is not.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isNormalized → bool
-
Whether these constraints satisfy the invariant: 0 <= min <= max.
no setter
- isTight → bool
-
Whether these constraints force an exact size in both dimensions.
no setter
- maxHeight → int
-
The maximum height constraint.
final
- maxWidth → int
-
The maximum width constraint.
final
- minHeight → int
-
The minimum height constraint.
final
- minWidth → int
-
The minimum width constraint.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
constrain(
Size size) → Size -
Returns a Size that satisfies these constraints given the proposed
size. -
deflate(
EdgeInsets edge) → BoxConstraints -
Returns new constraints reduced by the given
edgeinsets (e.g. padding). -
enforce(
BoxConstraints constraints) → BoxConstraints -
Returns new constraints that are clamped within the given
constraints. -
loosen(
) → BoxConstraints - Returns new constraints with the minimum width and height set to zero.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override