微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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',
  ];

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐