对其子级施加其他(minWidth,maxWidth,minHeight,maxHeight)约束
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 50,
minWidth: 50,
// minWidth: double.infinity, // //宽度尽可能大
),
child: _buildChild(
width: 50 + 10.0,
height: 40,
),
),
),
),
);
}
Container _buildChild({
double width,
double height,
}) {
return Container(
height: height,
width: width,
color: Colors.red,
);
}
}