2019.8.30 记录一个Swiper的使用

导入     flutter_swiper: ^1.1.6

引入     import 'package:flutter_screenutil/flutter_screenutil.dart';

已下是一个完整的swiper的代码

Container(
        height: 200,
        child: Swiper(
          itemCount: imagePaths.length,
          itemHeight: 200,
          itemWidth: 375,
          autoplay: true, // 自动播放
          layout: SwiperLayout.STACK, // 样式
          pagination: SwiperPagination(),// 添加一个页码指示器
          itemBuilder: (context, index) {
            return Container(
              color: Colors.grey,
              child: Image.network(
                imagePaths[index],
                fit: BoxFit.cover,
              ),
            );
          },
        ),
      )
final imagePaths = [
    'http://pic1.win4000.com/wallpaper/c/53cdd1f7c1f21.jpg',
    'http://pic25.nipic.com/20121112/9252150_150552938000_2.jpg',
    'http://pic51.nipic.com/file/20141025/8649940_220505558734_2.jpg',
    'http://gss0.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/lvpics/w=600/sign=1350023d79899e51788e391472a5d990/b21bb051f819861810d03e4448ed2e738ad4e65f.jpg',
    'http://a.hiphotos.baidu.com/lvpics/h=800/sign=5a82402cd5ca7bcb627bca2f8e086b3f/caef76094b36acaf0651ef137ed98d1000e99caf.jpg',
    'http://pic39.nipic.com/20140320/12795880_110914420143_2.jpg',
    'http://pic38.nipic.com/20140217/7643674_131828170000_2.jpg',
  ];
原文地址:https://www.cnblogs.com/110-913-1025/p/11434250.html