carousel_slider 1.0.1

  • Example
  • Installing
  • Versions
  • 94


A carousel slider widget, support infinite scroll and custom child widget, with autoplay feature.


Add carousel_slider: ^1.0.1 in your pubspec.yaml dependencies.

How to use

Simply create a CarouselSlider widget, and pass the required params:

new CarouselSlider(
  items: [1,2,3,4,5].map((i) {
    return new Builder(
      builder: (BuildContext context) {
        return new Container(
          width: MediaQuery.of(context).size.width,
          margin: new EdgeInsets.symmetric(horizontal: 5.0),
          decoration: new BoxDecoration(
            color: Colors.amber
          child: new Text('text $i', style: new TextStyle(fontSize: 16.0),)
  height: 400.0,
  autoPlay: true

For a more detail example please take a look at the example folder.



new CarouselSlider(
  items: items,
  viewportFraction: 0.8,
  initialPage: 0,
  aspectRatio: 16/9,
  height: 400,
  reverse: false,
  autoPlay: false,
  interval: const Duration(seconds: 4),
  autoPlayCurve: Curves.fastOutSlowIn,
  autoPlayDuration: const Duration(milliseconds: 800),
  updateCallback: someFunction,
  distortion: false

You can pass the above params to the class. If you pass the height params, the aspectRatio param will be ignore.

Instance methods

You can use the instance methods to programmatically take control of the pageView's position.

.nextPage({Duration duration, Curve curve})

Animate to the next page

.previousPage({Duration duration, Curve curve})

Animate to the previous page

.jumpToPage(int page)

Jump to the given page.

.animateToPage(int page, {Duration duration, Curve curve})

Animate to the given page.


Can I display a dotted indicator for the slider?

Yes, you can.

class CarouselWithIndicator extends StatefulWidget {
  _CarouselWithIndicatorState createState() => _CarouselWithIndicatorState();

class _CarouselWithIndicatorState extends State<CarouselWithIndicator> {
  int _current = 0;

  Widget build(BuildContext context) {
    return Stack(
      children: [
          items: child,
          autoPlay: true,
          aspectRatio: 2.0,
          updateCallback: (index) {
            setState(() {
              _current = index;
          top: 0.0,
          left: 0.0,
          right: 0.0,
          child: Row(
            children: map<Widget>(imgList, (index, url) {
              return Container(
                width: 8.0,
                height: 8.0,
                margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0),
                decoration: BoxDecoration(
                  color: _current == index ? Color.fromRGBO(0, 0, 0, 0.9) : Color.fromRGBO(0, 0, 0, 0.4)

The complete code is located in the example folder.


Initial version.


Remove useless dependencies, add changelog.


Fix initialPage bug, fix crash when widget is disposed.


Fix hard coded number


Added distortion option


Update doc



This exmaple shows four carousel slider examples:

  • Image slider with custom button control
  • Image slider with custom caption
  • Image slider with full width display
  • Image slider with indicator



flutter run


flutter build ios # or flutter build apk

Use this package as a library

1. Depend on it

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

  carousel_slider: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:carousel_slider/carousel_slider.dart';
Version Uploaded Documentation Archive
1.0.1 Dec 6, 2018 Go to the documentation of carousel_slider 1.0.1 Download carousel_slider 1.0.1 archive
1.0.0 Dec 6, 2018 Go to the documentation of carousel_slider 1.0.0 Download carousel_slider 1.0.0 archive
0.0.7 Aug 29, 2018 Go to the documentation of carousel_slider 0.0.7 Download carousel_slider 0.0.7 archive
0.0.6 Jul 8, 2018 Go to the documentation of carousel_slider 0.0.6 Download carousel_slider 0.0.6 archive
0.0.5 Jul 3, 2018 Go to the documentation of carousel_slider 0.0.5 Download carousel_slider 0.0.5 archive
0.0.4 May 8, 2018 Go to the documentation of carousel_slider 0.0.4 Download carousel_slider 0.0.4 archive
0.0.3 May 8, 2018 Go to the documentation of carousel_slider 0.0.3 Download carousel_slider 0.0.3 archive
0.0.2 Apr 17, 2018 Go to the documentation of carousel_slider 0.0.2 Download carousel_slider 0.0.2 archive
0.0.1 Apr 17, 2018 Go to the documentation of carousel_slider 0.0.1 Download carousel_slider 0.0.1 archive
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 Dec 6, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs (-9.52 points)

20 out of 21 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies