【问题标题】:Flutter: Nested ListView Overflow warningFlutter:嵌套的 ListView 溢出警告
【发布时间】:2021-01-27 18:10:55
【问题描述】:

我有一个这样的嵌套 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,
                                         ),
                                            ]
       

我正在尝试在 Container 内添加滚动效果。但是,我收到了The overflowing RenderFlex has an orientation of Axis.horizontal.

首先,我认为这是因为 Container 小部件没有高度和宽度。但看起来这不是问题,因为我仍然有错误。我尝试添加 Expanded 小部件或另一个 Container 小部件来设置高度和宽度。他们都没有修复Overflow 警告。

为了使ListViewAnimatedContainer 内可垂直滚动,我应该进行哪些调整?

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    也许您可以尝试将包装 ListView 的 Row 替换为水平方向、Container 或具有固定高度的东西。

    【讨论】:

      猜你喜欢
      • 2019-01-30
      • 2021-05-19
      • 2019-01-29
      • 2020-03-12
      • 2019-05-27
      • 1970-01-01
      • 2020-07-22
      • 1970-01-01
      • 2022-01-23
      相关资源
      最近更新 更多