flutter listview 横向滚动

刚开始思考着应该和android一样,默认垂直滚动,需要自定义,非常麻烦.
查阅官方文档,才发现只需要增加一行代码即可
ListView.builder(
      scrollDirection: Axis.horizontal,
      itemBuilder: (context, index) {
        final Axis slidableDirection =
            direction == Axis.horizontal ? Axis.vertical : Axis.horizontal;
        if (index == 0) {
          return ConversationXMPPStatues(connectState); //通知信息
        } else {
          return _getSlidableWithLists(
              context, index, slidableDirection, list[index - 1]);
        }
      },
      itemCount: (list?.length != null) ? (list.length + 1) : 1,
    );

flutter listview 横向滚动_第1张图片
喜欢可以加Q群号:913934649,点赞,评论;

简书: https://www.jianshu.com/u/88db5f15770d

csdn:https://me.csdn.net/beyondforme

掘金:https://juejin.im/user/5e09a9e86fb9a016271294a7

你可能感兴趣的:(flutter,flutter,listview,横向滚动,dart)