Flutter——輪播

flutter_swiper: flutter最強大的siwiper, 多種佈局方式,無限輪播,Android和IOS雙端適配.


1,添加依賴

flutter_swiper: ^1.1.6
複製代碼

2,下載依賴

flutter pub get複製代碼


3,導入依賴

import 'package:flutter_swiper/flutter_swiper.dart';
複製代碼

4,簡單使用

class MySwiper extends StatefulWidget {
  @override
  _MySwiperState createState() => _MySwiperState();
}

class _MySwiperState extends State<MySwiper> {
  @override
  Widget build(BuildContext context) {
    return Container(
        child: Swiper(
          itemBuilder: (context,position){
            return Image.network("http://pic1.win4000.com/pic/9/6d/cbc11464568.jpg");
          },
          itemCount: 3,
          pagination: SwiperPagination(),
          control: SwiperControl(),
          viewportFraction: 0.8,
          scale: 0.9,
        ),

    );
  }
}複製代碼

5,示例(官方文檔比較詳細:點擊進入)

相關文章
相關標籤/搜索