flutter纵向滚动嵌套横向滚动

如何在纵向滚动中插入横向滚动列表呢?

   return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        return SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Row(
            children: urls.map((item) {
              return Container(
                margin: const EdgeInsets.all(5.0),
                height: 80.0,
                width: 80.0,
                decoration: BoxDecoration(
                  image: DecorationImage(
                      image: NetworkImage(item),
                      fit: BoxFit.cover),
                ),
              );
            }).toList(),
          ),
        );
      },
    );

使用SingleChildScrollView,然后设置scrollDirection为Axis.horizontal,嵌套一个raw就行了

你可能感兴趣的:(flutter)