Flutter 颤栗:ListView里的一行给了我权利溢出
我想修复我的Flutter 颤栗:ListView里的一行给了我权利溢出,flutter,Flutter,我想修复我的图标容器,然后使卡容器可滚动。然而,我得到了正确的溢出错误。我认为这是因为图标容器的宽度。如何使图标固定在适当的位置,同时使ListView垂直滚动 return Row( children: [ Container( height: 150, color: Colors.amber, child: Column( mainAxisAlignment: MainAxisAl
图标容器
,然后使卡容器
可滚动。然而,我得到了正确的溢出错误。我认为这是因为图标容器的宽度。如何使图标固定在适当的位置,同时使ListView垂直滚动
return Row(
children: [
Container(
height: 150,
color: Colors.amber,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
iconSize: 20,
icon: Icon(Icons.add_circle_outline),
onPressed: () {
print('hello');
},
),
],
),
),
Container(
color: Colors.white,
height: 150,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: [
Card(
child: Container(
color: Colors.grey,
width: 150,
child: Text('hello'),
),
),
),
Card(
child: Container(
color: Colors.grey,
width: 150,
),
),
),
],
),
),
],
);
-----编辑
上面代码的结果是这样的。我想做的是
- 图标按钮位于固定位置
- 卡片可以水平滚动
没有右溢出
警告
尝试用展开的:
return Row(
children: [
Container(
height: 150,
color: Colors.amber,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
iconSize: 20,
icon: Icon(Icons.add_circle_outline),
onPressed: () {
print('hello');
},
),
],
),
),
Expanded(child:
Container(
color: Colors.white,
height: 150,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: [
Card(
child: Container(
color: Colors.grey,
width: 150,
child: Text('hello'),
),
),
),
Card(
child: Container(
color: Colors.grey,
width: 150,
),
),
),
],
),),
),
],
);
在您的代码中,您必须将滚动方向定义为水平,改进您的问题,并清楚地写下您到底想做什么?请也改进您提交的代码,以便我们能够找到问题。对不起,各位。我以为照片包括在内了。我刚刚编辑过