Flutter-圖片輪播flutter_swiper
Posted ssjf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter-圖片輪播flutter_swiper相关的知识,希望对你有一定的参考价值。
pubspec.yaml
flutter_swiper: ^1.0.6 //请在pub上查看最新版本
使用
import ‘package:flutter/material.dart‘; import ‘package:flutter_swiper/flutter_swiper.dart‘; class AlbumPage extends StatefulWidget { @override AlbumPageState createState() { return AlbumPageState(); } } class AlbumPageState extends State<AlbumPage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(‘轮播组件‘), ), body: Container( width: MediaQuery.of(context).size.width, height: 200.0, child: Swiper( itemBuilder: _swiperBuilder, itemCount: 3, pagination: SwiperPagination( builder: DotSwiperPaginationBuilder( color: Colors.black54, activeColor: Colors.white, )), control: SwiperControl(), scrollDirection: Axis.horizontal, autoplay: true, onTap: (index) => print(‘点击了第$index个‘), )), ); } Widget _swiperBuilder(BuildContext context, int index) { return (Image.network( "http://via.placeholder.com/350x150", fit: BoxFit.fill, )); } }
來源:https://blog.csdn.net/u011272795/article/details/82776861
以上是关于Flutter-圖片輪播flutter_swiper的主要内容,如果未能解决你的问题,请参考以下文章
Flutter监听滚动动作 控制组件 透明度渐变 ( 移除顶部状态栏空白 | 帧布局组件 | 透明度组件 | 监听滚动组件 )