flutter_banner_swiper 0.1.4

Flutter Android iOS web

A banner swiper package. banner swiper use the libray PageView swrap form the new widget.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_banner_swiper/flutter_banner_swiper.dart';
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("title"),
        ),
        body:   Myexample(),
      )
    );
  }
}


class Myexample extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return _MyexampleState();
  }

}
class _MyexampleState extends State<Myexample>{
  @override
  void initState() {
    bannerList.add("http:\/\/minimg.hexun.com\/i4.hexunimg.cn\/mobile_show\/image\/20190701\/20190701121331_376_621x310.jpg");
    bannerList.add("http:\/\/minimg.hexun.com\/i7.hexun.com\/2015-11-16\/180596378_c324x234.jpg");
    bannerList.add("http:\/\/minimg.hexun.com\/i6.hexun.com\/2014-11-19\/170564509_c324x234.jpg");
    bannerList.add("http:\/\/minimg.hexun.com\/i7.hexun.com\/2014-09-02\/168105362_c324x234.jpg");
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return getList();
  }

  List<String> bannerList=new List();
  Widget getList() {
    return BannerSwiper(
      //width  和 height 是图片的高宽比  不用传具体的高宽   必传
      height: 108,
      width: 54,
      //轮播图数目 必传
      length: 4,
      //轮播的item  widget 必传
      getwidget: (index) {
        return new GestureDetector(
            child: Image.network(
              bannerList[index % bannerList.length],
              fit: BoxFit.cover,
            ),
            onTap: () {
              //点击后todo
            });
      },
    );
  }

}
9
likes
90
pub points
78%
popularity

A banner swiper package. banner swiper use the libray PageView swrap form the new widget.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

liuwangle1789@gmail.com

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_banner_swiper