简体   繁体   English

Flutter:嵌套列表视图溢出警告

[英]Flutter: Nested ListView Overflow warning

I have a nested ListView like this.我有一个这样的嵌套 ListView。

  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.但是,我得到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.首先,我认为这是因为Container小部件没有高度和宽度。 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.我尝试添加Expanded小部件或另一个Container小部件来设置高度和宽度。 None of them fixing the Overflow warning.他们都没有修复Overflow警告。

What should I have to adjust in order to make the ListView vertically scrollable inside the AnimatedContainer ?为了使ListViewAnimatedContainer内可以垂直滚动,我应该调整什么?

Maybe you could try replace the Row that wrapper the ListView with horizontal direction, with a Container or something with fixed height.也许您可以尝试将包装 ListView 的 Row 替换为水平方向、Container 或具有固定高度的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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