我正在尝试使 Container 的内容可滚动,我认为我可能误用了 SingleChildScrollView 小部件。
是否可以将它放在Container(作为它的子级)的内部,因为我希望它的内容可以滚动?
谢谢。
Hero(
tag: this.widget.id,
child: Material(
type: MaterialType.transparency,
child: Center(
child: Container(
margin: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.25),
height: MediaQuery.of(context).size.height * 0.75,
width: MediaQuery.of(context).size.width * 0.95,
decoration: cardDecoration,
child: SingleChildScrollView(
child: ContentTripExtract(this.widget.i, false) // a column of texts and containers
),
),
),
),
),
最佳答案
你需要像这样指定SingleChildScrollView只有一个 child :
child: SingleChildScrollView(
child: Container(
并且不要在 subview 中使用 flex。 在你的情况下,我认为它有效
child: SingleChildScrollView(
child: Container(
child: ContentTripExtract(this.widget.i, false) // a column of texts and containers
),
关于flutter - SingleChildScrollView 错误 "RenderFlex children have non-zero flex but incoming height constraints are unbounded",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56833382/