frameConstrained method
A similar extension to frame, but that uses BoxConstraints instead of hardcoded size values.
Implementation
Widget frameConstrained({
required double maxWidth,
required double minHeight,
required double minWidth,
required double maxHeight,
double? idealHeight,
Alignment? alignment,
double? idealWidth,
}) {
Widget content = this;
if (alignment != null) {
content = Align(
alignment: alignment,
child: this,
);
}
final ConstrainedBox box = ConstrainedBox(
constraints: BoxConstraints(
minWidth: minWidth,
maxWidth: maxWidth,
minHeight: minHeight,
maxHeight: maxHeight,
),
child: content,
);
if (idealWidth != null || idealHeight != null) {
return SizedBox(
width: idealWidth,
height: idealHeight,
child: box,
);
}
return box;
}