constrained method
Imposes additional constraints on its child.
Only boxConstraints
or minWidth
, maxWidth
, minHeight
, and
maxHeight
can be provided. Providing both a constraint and min/max
values will throw an assertion error.
Implementation
Widget constrained({
Key? key,
BoxConstraints? boxConstraints,
double? minWidth,
double? maxWidth,
double? minHeight,
double? maxHeight,
}) {
assert(
boxConstraints == null ||
(minWidth == null &&
maxWidth == null &&
minHeight == null &&
maxHeight == null),
'Cannot provide both a constraint and min/max values.',
);
return ConstrainedBox(
key: key,
constraints: boxConstraints ??
BoxConstraints(
minWidth: minWidth ?? 0,
maxWidth: maxWidth ?? double.infinity,
minHeight: minHeight ?? 0,
maxHeight: maxHeight ?? double.infinity,
),
child: this,
);
}