flutter swiper 使用
2020年7月14日 19:03
编程技术
添加项目依赖
flutter_swiper : any
使用
Container(
    width: MediaQuery.of(context).size.width,
    height: 200.0,
    child: Swiper(
        itemBuilder: (context, index) =>
            CachedNetworkImage(imageUrl: banners[index].content),
        itemCount: banners.length,
        autoplay: true,
        loop: true,
    ),
)
注意
必须放到 一个父元素了,不能直接放到  <Widget>[] 中作为一个子元素,原因是必须指定尺寸,即宽和高