flutter_banner_swiper 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

flutter_banner_swiper #

A banner swiper package.

Getting Started #

Installing

flutter_banner_swiper: ^0.1.4

Import

import 'package:flutter_banner_swiper/flutter_banner_swiper.dart';

How To Use

最简单的应用

     BannerSwiper(

           //width  和 height 是图片的高宽比  不用传具体的高宽   必传
           height: 108,
           width: 54,
           //轮播图数目 必传
           length: bannerList.length,

           //轮播的item  widget 必传
           getwidget: (index) {
             return new GestureDetector(
                 child:  Image.network(bannerList[index % bannerList.length].img,fit: BoxFit.cover,),
                 onTap: () {
                   //点击后todo
                 });
           },
         );

复杂点的

BannerSwiper( //是否显示指示器 默认true showIndicator: false, //是否自动循环翻页 默认true autoLoop: false, //自定义 未选中指示器 normalWidget: Container( width: 10, height: 10, color: Colors.white, ), //自定义 选中指示器 selectorWidget: Container( width: 10, height: 10, color: Colors.black38, ),

   //width  和 height 是图片的高宽比  不用传具体的高宽   必传
   height: 108,
   width: 54,
   //轮播图数目 必传
   length: bannerList.length,

   //轮播的item  widget 必传
   getwidget: (index) {
     return new GestureDetector(
         child:  Image.network(bannerList[index % bannerList.length].img,fit: BoxFit.cover,),
         onTap: () {
           //点击后todo
         });
   },
 );

默认spaceMode=true效果 image

默认spaceMode=false效果 image

[0.0.7] - 2019.6.27

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
            });
      },
    );
  }

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_banner_swiper: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_banner_swiper/flutter_banner_swiper.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
72
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Oct 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/banner_indicator.dart. (-0.50 points)

Analysis of lib/banner_indicator.dart reported 1 hint:

line 3 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: SquareIndicator.length, SquareIndicator.select, SquareIndicator.mSquareIndicator

Fix lib/flutter_banner_swiper.dart. (-0.50 points)

Analysis of lib/flutter_banner_swiper.dart reported 1 hint:

line 47 col 18: Don't explicitly initialize variables to null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test