【发布时间】:2020-12-26 18:00:43
【问题描述】:
我正在尝试在 Flutter 中创建 Instagram 样式的列表视图,其中顶部的水平滚动是故事,而下面的滚动部分是帖子的垂直滚动部分。我现在只是使用列表视图,而不是列表视图构建器。但不知何故,我的输出中没有垂直滚动。另外,在上面的列表视图中,容器大小采用父容器的大小 100,而不是高度 80。我该如何解决这个问题?
下面是代码:
body: Column(
children: [
Container(
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.red,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.blue,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
],
),
),
SizedBox(
height: 10,
),
ListView(
scrollDirection: Axis.vertical,
children: [
Container(
height: 100,
color: Colors.red,
),
Container(
height: 100,
color: Colors.blue,
),
Container(
height: 100,
color: Colors.green,
),
],
)
],
)
这是我的输出:
【问题讨论】: