【发布时间】:2021-01-27 18:10:55
【问题描述】:
我有一个这样的嵌套 ListView。
AnimatedContainer(
width: MediaQuery.of(context).size.width * 0.90,
height: MediaQuery.of(context).size.height * 0.45,
child: Stack(
children: [
Positioned(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.30,
width: MediaQuery.of(context).size.width * 0.90,
child: Column(
children: [
Container(
width: 300,
height: MediaQuery.of(context).size.height * 0.20,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('hmm'),
Row(
ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: [
Container(
height: 40,
width: 200,
color: Colors.white,
),
Container(
height: 40,
width: 200,
color: Colors.white,
),
Container(
height: 40,
width: 200,
color: Colors.white,
),
]
我正在尝试在 Container 内添加滚动效果。但是,我收到了The overflowing RenderFlex has an orientation of Axis.horizontal.
首先,我认为这是因为 Container 小部件没有高度和宽度。但看起来这不是问题,因为我仍然有错误。我尝试添加 Expanded 小部件或另一个 Container 小部件来设置高度和宽度。他们都没有修复Overflow 警告。
为了使ListView 在AnimatedContainer 内可垂直滚动,我应该进行哪些调整?
【问题讨论】: