SingleChildScrollView错误“ RenderFlex子代的Flex值非零,但传入的高度限制不受限制”

时间:2019-07-01 09:45:02

标签: flutter dart

我正在尝试使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
                    ),
                ),
              ),
            ),
          ),

1 个答案:

答案 0 :(得分:1)

您需要指定 SingleChildScrollView 仅具有一个孩子,如下所示:

 child: SingleChildScrollView(
        child: Container(

也不要在子视图中使用flex。 就您而言,我认为它可行

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