最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

flutter實(shí)現(xiàn)輪播圖效果

 更新時(shí)間:2019年07月17日 12:06:07   作者:早起的年輕人  
這篇文章主要為大家詳細(xì)介紹了flutter實(shí)現(xiàn)輪播圖效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android九宮格圖片展示的具體代碼,供大家參考,具體內(nèi)容如下

1 添加依賴庫(kù)

flutter_swiper: ^1.0.6

2 普通常用 圓點(diǎn)指示器自動(dòng)輪播圖

class SwiperViewDefaultPage extends StatefulWidget {
 @override
 State<StatefulWidget> createState() {
  return new SwiperViewDefaultPageState();
 }
}

class SwiperViewDefaultPageState
  extends BaseAppBarPageState<SwiperViewDefaultPage> {
 @override
 String buildInitState() {
  buildBackBar("輪播圖", backIcon: Icons.arrow_back_ios);
  return null;
 }

 @override
 Widget buildWidget(BuildContext context) {
  print("build --");
  return new Column(
   children: <Widget>[
    Padding(
     padding: EdgeInsets.all(10),
    ),
    buildStyle1(),
   ],
  );
 }

 // 分頁指示器
 buildSwiperPagination() {
  return SwiperPagination(
   //指示器顯示的位置
   alignment: Alignment.bottomCenter, // 位置 Alignment.bottomCenter 底部中間
   // 距離調(diào)整
   margin: const EdgeInsets.fromLTRB(0, 0, 0, 5),
   // 指示器構(gòu)建
   builder: DotSwiperPaginationBuilder(
     // 點(diǎn)之間的間隔
     space: 2,
     // 沒選中時(shí)的大小
     size: 6,
     // 選中時(shí)的大小
     activeSize: 12,
     // 沒選中時(shí)的顏色
     color: Colors.black54,
     //選中時(shí)的顏色
     activeColor: Colors.white),
  );
 }

 //banner 圖
 Widget buildStyle1() {
  return Container(
   height: 200.0,
   child: new Swiper(
    // 橫向
    scrollDirection: Axis.horizontal,
    // 布局構(gòu)建
    itemBuilder: (BuildContext context, int index) {
     return new Image.network(
      "http://hbimg.b0.upaiyun.com/a3e592c653ea46adfe1809e35cd7bc58508a6cb94307-aaO54C_fw658",
      fit: BoxFit.fill,
     );
    },
    //條目個(gè)數(shù)
    itemCount: 6,
    // 自動(dòng)翻頁
    autoplay: true,
    // 分頁指示
    pagination: buildPlugin(),
    //點(diǎn)擊事件
    onTap: (index) {
     print(" 點(diǎn)擊 " + index.toString());
    },
    // 相鄰子條目視窗比例
    viewportFraction: 1,
    // 布局方式
    //layout: SwiperLayout.STACK,
    // 用戶進(jìn)行操作時(shí)停止自動(dòng)翻頁
    autoplayDisableOnInteraction: true,
    // 無線輪播
    loop: true,
    //當(dāng)前條目的縮放比例
    scale: 1,
   ),
  );
 }

 buildPlugin() {
  return SwiperPagination();
 }
}

3 自定圓點(diǎn)分頁指示器 效果

 //自定圓點(diǎn)分頁指示器
 buildSwiperPagination() {
  // 分頁指示器
  return SwiperPagination(
   //指示器顯示的位置
   alignment: Alignment.bottomCenter, // 位置 Alignment.bottomCenter 底部中間
   // 距離調(diào)整
   margin: const EdgeInsets.fromLTRB(0, 0, 0, 5),
   // 指示器構(gòu)建
   builder: DotSwiperPaginationBuilder(
     // 點(diǎn)之間的間隔
     space: 2,
     // 沒選中時(shí)的大小
     size: 6,
     // 選中時(shí)的大小
     activeSize: 12,
     // 沒選中時(shí)的顏色
     color: Colors.black54,
     //選中時(shí)的顏色
     activeColor: Colors.white),
  );
 }

 //定義輪播圖組件
 Widget buildStyle1() {
  return Container(
   height: 200.0,
   child: new Swiper(
    // 橫向
    scrollDirection: Axis.horizontal,
    // 布局構(gòu)建
    itemBuilder: (BuildContext context, int index) {
     return new Image.network(
      "http://hbimg.b0.upaiyun.com/a3e592c653ea46adfe1809e35cd7bc58508a6cb94307-aaO54C_fw658",
      fit: BoxFit.fill,
     );
    },
    //條目個(gè)數(shù)
    itemCount: 6,
    // 自動(dòng)翻頁
    autoplay: true,
    // 分頁指示
    pagination: buildSwiperPagination(),
    //點(diǎn)擊事件
    onTap: (index) {
     print(" 點(diǎn)擊 " + index.toString());
    },
    // 視窗比例
    viewportFraction: 1,
    // 布局方式
    //layout: SwiperLayout.STACK,
    // 用戶進(jìn)行操作時(shí)停止自動(dòng)翻頁
    autoplayDisableOnInteraction: true,
    // 無線輪播
    loop: true,
    scale: 1,
   ),
  );
 }

4 自定數(shù)字 分頁指示器 效果

 //自定義分頁指示器
 buildSwiperPagination() {
  // 分頁指示器
  return SwiperPagination(
   //指示器顯示的位置
   alignment: Alignment.bottomCenter, // 位置 Alignment.bottomCenter 底部中間
   // 距離調(diào)整
   margin: const EdgeInsets.fromLTRB(0, 0, 0, 5),
   // 指示器構(gòu)建
   builder: FractionPaginationBuilder(
     // 選中時(shí)字體大小
     activeFontSize: 14,
     // 字體大小
     fontSize: 14,
      // 字體顏色
     color: Colors.red,
     //選中時(shí)的顏色
     activeColor: Colors.blue),
  );
 }

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

秦安县| 兴义市| 西林县| 赞皇县| 珲春市| 象州县| 精河县| 江阴市| 苗栗县| 碌曲县| 邹平县| 株洲县| 吉首市| 中方县| 保德县| 宜宾县| 临武县| 来宾市| 兴城市| 洛南县| 蓬溪县| 嘉定区| 苍梧县| SHOW| 安乡县| 乐亭县| 来安县| 沁水县| 永康市| 忻城县| 融水| 南京市| 南昌市| 南川市| 柯坪县| 南康市| 湘潭市| 卓尼县| 特克斯县| 临潭县| 洛川县|