首页 > 解决方案 > Flutter 中的轮播布局

问题描述

如何使轮播布局视图寻呼机像图像滑块一样自动递增,就像在 android 中我们使用视图寻呼机自动滚动一样。

标签: flutter

解决方案


利用

列表视图(来源

ListView(
  // This next line does the trick.
  scrollDirection: Axis.horizontal,
  children: <Widget>[
    Container(
      width: 160.0,
      color: Colors.red,
    ),
    Container(
      width: 160.0,
      color: Colors.blue,
    ),
    Container(
      width: 160.0,
      color: Colors.green,
    ),
    Container(
      width: 160.0,
      color: Colors.yellow,
    ),
    Container(
      width: 160.0,
      color: Colors.orange,
    ),
  ],
)

在此处输入图像描述


推荐阅读