Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

Flutter: Nested ListView Overflow warning

I have a nested ListView like this.

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

I am trying to have a scroll effect inside the Container. However, I am getting The overflowing RenderFlex has an orientation of Axis.horizontal.

First, I'd thought it was because of the Container widget did not have height and width. But it doesn't look like it was a problem since I still have the error. I've tried to add Expanded widget or another Container widget to set the height and width. None of them fixing the Overflow warning.

What should I have to adjust in order to make the ListView vertically scrollable inside the AnimatedContainer?

question from:https://stackoverflow.com/questions/65924915/flutter-nested-listview-overflow-warning

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Maybe you could try replace the Row that wrapper the ListView with horizontal direction, with a Container or something with fixed height.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...