简体   繁体   中英

SingleChildScrollView error “RenderFlex children have non-zero flex but incoming height constraints are unbounded”

I am trying to make the content of a Container scrollable, and I think that I probably mis-use the SingleChildScrollView widget.

Is it okay to put it inside of a Container (as its child) because I want its content to be scrollable ?

Thanks.

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
                    ),
                ),
              ),
            ),
          ),

You need to specify that the SingleChildScrollView has only one child like this:

 child: SingleChildScrollView(
        child: Container(

And don't Use flex in the child views. In your case, I think it works

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM