constraints method
Widget
constraints({
- double? minWidth,
- double? maxWidth,
- double? minHeight,
- double? maxHeight,
- BoxConstraints? constraints,
- bool overflow = false,
- AlignmentGeometry? alignment,
Applies additional constraints to this widget.
Implementation
@widgetFactory
Widget constraints({
double? minWidth,
double? maxWidth,
double? minHeight,
double? maxHeight,
BoxConstraints? constraints,
bool overflow = false,
AlignmentGeometry? alignment,
}) {
assert(
overflow || alignment == null,
'alignment can only be used with overflow',
);
assert(() {
_debugCheckParameterCombinations(modifier: 'constraints', [
{
'minWidth': minWidth,
'maxWidth': maxWidth,
'minHeight': minHeight,
'maxHeight': maxHeight,
},
{'constraints': constraints},
]);
return true;
}());
if (overflow) {
return FleetOverflowBox(
minHeight: minHeight ?? constraints?.minHeight,
maxHeight: maxHeight ?? constraints?.maxHeight,
minWidth: minWidth ?? constraints?.minWidth,
maxWidth: maxWidth ?? constraints?.maxWidth,
alignment: alignment ?? Alignment.center,
child: this,
);
} else {
constraints ??= BoxConstraints(
minWidth: minWidth ?? 0,
maxWidth: maxWidth ?? double.infinity,
minHeight: minHeight ?? 0,
maxHeight: maxHeight ?? double.infinity,
);
return FleetConstrainedBox(
constraints: constraints,
child: this,
);
}
}