【问题标题】:Another exception was thrown: A RenderFlex overflowed by 265 pixels on the right on Flutter又抛出了一个异常:A RenderFlex 在 Flutter 上右边溢出了 265 像素
【发布时间】:2019-11-04 08:06:34
【问题描述】:

我是 Flutter 的新手。如何在 Row 中应用水平滚动视图。如果可行,请给我一个解决方案,然后我接受您的回答这里有人对此有解决方案吗?提前致谢。这是我的代码。

  Row(
            // crossAxisAlignment: CrossAxisAlignment.start,
            children: categoryData.map((i) {
              print('i====>>>>>>>>>>>>>>>>>.${i['name']}');
              scrollDirection:
              Axis.horizontal;
              return FlatButton(
                color: Colors.blue,
                textColor: Colors.white,
                disabledColor: Colors.grey,
                disabledTextColor: Colors.black,
                padding: EdgeInsets.all(8.0),
                splashColor: Colors.blueAccent,
                onPressed: () {
                  /*...*/
                },
                child: Text(
                  '${i['name']}',
                  style: TextStyle(fontSize: 12.0),
                ),
              );
            }).toList(),
          ),

【问题讨论】:

  • 代码中的滚动视图在哪里?
  • 如果您还没有添加滚动视图,请检查答案。

标签: flutter dart


【解决方案1】:

Row 中没有参数scrollDirection。将滚动视图放在 ROW 的顶部。喜欢

SingleChildScrollView(
  scrollDirection: Axis.horizontal,
  child: Row(.....),
)

【讨论】:

    【解决方案2】:

    使用 ListView 代替 Row

    ListView(
          scrollDirection: Axis.horizontal,
          children: <Widget>[
             FlatButton(...),
             FlatButton(...),
             FlatButton(...),
          ],
        )
    

    ...

    【讨论】:

      猜你喜欢
      • 2021-12-11
      • 2020-07-28
      • 2019-06-07
      • 2021-05-14
      • 1970-01-01
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      相关资源
      最近更新 更多