
2.
// ConstrainedBox,添加约束
class ConstrainedBoxDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: [
// 不添加限制
Container(
width: 350,
height: 80,
child: Text('width>maxWidthxxxxxxxxxxxxxxxxxxxxxxx'),
color: Colors.green,
),
SizedBox(height: 50,),
// 添加一个指定大小的盒子,限定其最大最小宽高
ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 200.0,
minWidth: 100.0,
maxHeight: 60.0,
minHeight: 20.0,
),
child: Container(
width: 350,
height: 80,
child: Text('width>maxWidthxxxxxxxxxxxxxxxxxxxxxxxxxx'),
color: Colors.green,
),
)
],
),
);
}
}
由于给定内容仅为数字‘2’,缺乏关键信息,无法生成有效摘要。

被折叠的 条评论
为什么被折叠?



