flutter_swiper 1.1.6


Build Status Coverage Status PRs Welcome pub package best-flutter


flutter_swiper #

The best swiper for flutter , with multiple layouts, infinite loop. Compatible with Android & iOS.

✨✨ New Features:Layout for pagination.

We are using this project flutter_page_indicator now .

✨✨ New Features:PageTransformer

Finally, we have PageTransformer like android, just set a transformer to Swiper, it returns a widget that has been transformed. For now, only support for layout DEFAULT. Thanks to @FlutterRocks ,you've done great job 👏.

We are using this project transformer_page_view now .

✨✨ New Features:Layout

See More

Showcases #



Custom Pagination

Custom Pagination



See More

Roadmap #


Changelogs #


Getting Started #

Installation #


flutter_swiper : ^lastest_version

to your pubspec.yaml ,and run

flutter packages get 

in your project's root directory.

Basic Usage #

Create a new project with command

flutter create myapp

Edit lib/main.dart like this:

import 'package:flutter/material.dart';

import 'package:flutter_swiper/flutter_swiper.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      home: new MyHomePage(title: 'Flutter Demo Home Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  _MyHomePageState createState() => new _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
    body:  new Swiper(
        itemBuilder: (BuildContext context,int index){
          return new Image.network("http://via.placeholder.com/350x150",fit: BoxFit.fill,);
        itemCount: 3,
        pagination: new SwiperPagination(),
        control: new SwiperControl(),

Constructor #

Basic #

scrollDirectionAxis.horizontalIf Axis.horizontal, the scroll view's children are arranged horizontally in a row instead of vertically in a column.
looptrueSet to false to disable continuous loop mode.
index0Index number of initial slide.
autoplayfalseSet to true enable auto play mode.
onIndexChangedvoid onIndexChanged(int index)Called with the new index when the user swiped or autoplay
onTapvoid onTap(int index)Called when user tap ui.
duration300.0The milliscends of every transaction animation costs
paginationnullset new SwiperPagination() to show default pagination
controlnullset new SwiperControl() to show default control buttons

Pagination #

The pagination extends from SwiperPlugin,the SwiperPlugin provides extra ui for Swiper.Set new SwiperPagination() to show default pagination.

alignmentAlignment.bottomCenterChange this value if you what to put pagination in other place
marginconst EdgeInsets.all(10.0)The distance between inner side of the parent container.
builderSwiperPagination.dotsThere are two default styles SwiperPagination.dots and SwiperPagination.fraction,both can be customized.

If you'd like to customize your own pagination, you can do like this:

new Swiper(
    pagination:new SwiperCustomPagination(
        builder:(BuildContext context, SwiperPluginConfig config){
            return new YourOwnPaginatipon();

Control buttons #

The control also extends from SwiperPlugin,set new SwiperControl() to show default control buttons.

iconPreviousIcons.arrow_back_iosThe icon data to display previous control button
iconNextIcons.arrow_forward_iosThe icon data to display next.
colorTheme.of(context).primaryColorControl button color
size30.0Control button size
paddingconst EdgeInsets.all(5.0)Control button padding

Controller #

The Controller is used to control the index of the Swiper, start or stop autoplay.You can create a controller by new SwiperController() and save the instance by futher usage.

void move(int index, {bool animation: true})Move to the spicified index,with animation or not
void next({bool animation: true})Move to next
void previous({bool animation: true})Move to previous
void startAutoplay()Start autoplay
void stopAutoplay()Stop autoplay

Autoplay #

autoplayDelay3000Autoplay delay milliseconds.
autoplayDisableOnInteractiontrueIf set true, autoplay is disabled when use swipes.

Build in layouts #

new Swiper(
  itemBuilder: (BuildContext context, int index) {
    return new Image.network(
      fit: BoxFit.fill,
  itemCount: 10,
  viewportFraction: 0.8,
  scale: 0.9,

new Swiper(
  itemBuilder: (BuildContext context, int index) {
    return new Image.network(
      fit: BoxFit.fill,
  itemCount: 10,
  itemWidth: 300.0,
  layout: SwiperLayout.STACK,

new Swiper(
    itemBuilder: (BuildContext context, int index) {
      return new Image.network(
        fit: BoxFit.fill,
    itemCount: 10,
    itemWidth: 300.0,
    itemHeight: 400.0,
    layout: SwiperLayout.TINDER,

Very easy to create you own custom animation:

 new Swiper(
  layout: SwiperLayout.CUSTOM,
  customLayoutOption: new CustomLayoutOption(
      startIndex: -1,
      stateCount: 3
    new Offset(-370.0, -40.0),
    new Offset(0.0, 0.0),
    new Offset(370.0, -40.0)
  itemWidth: 300.0,
  itemHeight: 200.0,
  itemBuilder: (context, index) {
    return new Container(
      color: Colors.grey,
      child: new Center(
        child: new Text("$index"),
  itemCount: 10)

The CustomLayoutOption is designed to describe animations. It is very easy to specify every state of items in Swiper.

new CustomLayoutOption(
      startIndex: -1,  /// Which index is the first item of array below      
      stateCount: 3    /// array length 
  ).addRotate([        // rotation of every item 
  ]).addTranslate([           /// offset of every item
    new Offset(-370.0, -40.0),
    new Offset(0.0, 0.0),
    new Offset(370.0, -40.0)

Codes #


new ConstrainedBox(
  child: new Swiper(
    itemBuilder: (c, i) {
      return new Wrap(
        runSpacing:  6.0,
        children: [0,1,2,3,4,5,6,7,8,9].map((i){
          return new SizedBox(
            width: MediaQuery.of(context).size.width/5,
            child: new Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                new SizedBox(
                  child:  new Container(
                    child: new Image.network("https://fuss10.elemecdn.com/c/db/d20d49e5029281b9b73db1c5ec6f9jpeg.jpeg%3FimageMogr/format/webp/thumbnail/!90x90r/gravity/Center/crop/90x90"),
                  height: MediaQuery.of(context).size.width * 0.12,
                  width: MediaQuery.of(context).size.width * 0.12,
                new Padding(padding: new EdgeInsets.only(top:6.0),child: new Text("$i"),)
    pagination: new SwiperPagination(
      margin: new EdgeInsets.all(5.0)
    itemCount: 10,
    constraints:new BoxConstraints.loose(new Size(screenWidth, 170.0))

You can find all custom options here:


[1.1.5] - [2019/03/10]

  • Fix findRenderObject is null

[1.1.4] - [2018/10/18]

[1.1.2] - [2018/10/10]

* Fix #7
* Support layout for pagination.

[1.1.1] - [2018/09/20]

* Fix `test` failure.

[1.1.0] - [2018/09/20]

* Fix index bug ,See #11
* Enable `autoplayDisableOnInteraction` property, if set `true`,disable autoplay when user swipes.

[1.0.7] - [2018/09/02]

* Don't call SwiperController's dispose when `Swiper` dispose.

[1.0.6] - [2018/08/28]

* Implement vertical scroll direction for `TINDER` and `STACK` layout, see #9

[1.0.5] - [2018/08/09]

* Add feature : support fade for `viewportFraction`

[1.0.4] - [2018/07/18]

* Fix some typo,thanks to [csharad](https://github.com/csharad)

[1.0.3] - [2018/07/18]

* Use new to create everything. See #5

[1.0.2] - [2018/07/16]

* Fix #4

[1.0.1] - [2018/07/11]

* Add layout (CUSTOM) so that you can create your own layout

[1.0.0] - [2018/07/08]

* Add layouts ( DEFAULT,STACK,TINDER )
* Allow to put pagination outer of the swiper container.

[0.0.9] - [2018/06/10]

* Add ci
* Add testcase

[0.0.8] - [2018/06/07]

* And chinese document
* Update infinity_page_view version to 1.0.0

[0.0.7] - [2018/05/24]

* The default color of pagination is ThemeData.scaffoldBackgroundColor and ThemeData.primaryColor
* The default color of control buttons is ThemeData.primaryColor and ThemeData.disabledColor
* The alignment of pagination is Alignment.bottomCenter by default when scrollDirection== Axis.horizontal, Alignment.centerRight by default when scrollDirection== Axis.vertical
* Change default value of `autoplay` to false

[0.0.6] - [2018/05/24]

* Fix index bug

[0.0.5] - [2018/05/24]

* Fix zero itemCount bug

[0.0.4] - [2018/05/20]

* Update README

[0.0.3] - [2018/05/20]

* Update README
* Support none loop mode
* Add more examples

[0.0.2] - [2018/05/20]

* Autoplay
* Plugins support 
* Examples

[0.0.1] - [2018/05/20]

* Infinite loop
* Control buttons
* Pagination
* Custom control buttons
* Custom pagination
* Controler


example #

A new Flutter project.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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

  flutter_swiper: ^1.1.6

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_swiper/flutter_swiper.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.48.0 <3.0.0
flutter 0.0.0
flutter_page_indicator ^0.0.3 0.0.3
transformer_page_view ^0.1.6 0.1.6
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies