SingleChildScrollView错误 "RenderFlex子项具有非零的伸缩因子,但传入的高度约束未被限制"

4

我想让一个容器的内容可滚动,我认为我可能误用了SingleChildScrollView小部件。

如果我希望其内容可滚动,将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
                    ),
                ),
              ),
            ),
          ),
1个回答

3

您需要指定 SingleChildScrollView 只有一个子组件,如下:

 child: SingleChildScrollView(
        child: Container(

不要在子视图中使用flex。 根据您的情况,我认为它可以工作。

child: SingleChildScrollView(
child: Container(
child: ContentTripExtract(this.widget.i, false) // a column of texts and containers
  ),

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接