flutter_multi_carousel 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 92

Flutter_Carosel #

A simple Carousel Widget with multiple configuration option.

...
dependencies:
 ...
 flutter_multi_carousel: ^1.0.0
...

And install it using flutter packages get on your project folder. After that, just import the module and use it:

import 'package:flutter/material.dart';
import 'package:flutter_multi_carousel/carousel.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Carousel Demo',
      home: CarouselExample(),
    );
  }
}

class CarouselExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Carousel(
            height: 350.0,
            width: 350,
            initialPage: 3,
            allowWrap: false,
            type: Types.slideSwiper,
            onCarouselTap: (i) {
              print("onTap $i");
            },
            indicatorType: IndicatorTypes.bar,
            arrowColor: Colors.black,
            axis: Axis.horizontal,
            showArrow: true,
            children: List.generate(
                7,
                (i) => Center(
                      child:
                          Container(color: Colors.red.withOpacity((i + 1) / 7)),
                    ))),
      ),
    );
  }
}

https://github.com/jaiswalshubham84/Flutter-Carousel

Getting Startedslide #

Properties Type Default Value Description
height Double null Defines height of carousel.This field is required
width Double null Defines width of carousel. This field is required
axis Axis Axis.horizontal Defines axis of carousel.
type Types "simple" Defines type of carousel.
for ex: Types.simple, Types.slideSwiper, Types.xRotating, Types.yRotating, Types.zRotating, Types.multiRotating
onCarouselTap Function null A callback function
arrowColor Color Colors.white Define the color of arrow
arrowColor Color Colors.white Define the color of arrow
showIndicator Bool true Choice to show indicator in carousel
indicatorType IndicatorTypes bar Defines the type of indicator.
For ex: IndicatorTypes.bar, IndicatorTypes.dot, IndicatorTypes.bubble
initialPage int 0 Start your carousel with custom initial page number
activeIndicatorColor Color Colors.white Defines the color of active indicator
unActiveIndicatorColor Color Colors.black Defines the color of unactive indicator
indicatorBackgroundColor Color Color(0xff121212) Defines the background color of indicator
indicatorBackgroundOpacity Double 0.5 Defines the opacity of indicator background
allowWrap bool true Defines if the carousel should wrap once you reach the end or if your at the begining and go left if it should take you to the end


Credits #

Developed by Shubham Jaiswal jaiswal.shubham84@gmail.com

Contributing #

Feel free to Contribute!

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

[1.0.1] - 10 December 2017 #

  • Initial release.

[1.0.2] - 26 February 2019 #

  • Added feature to initialise the starting page index
  • Added a callback function on tap
  • Added wrap control to carousel
  • Indroduction of Types to select the type of carousel
  • Indroduction of IndicatorTypes to select the type of Indicator

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_multi_carousel/carousel.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Carousel Demo',
      home: CarouselExample(),
    );
  }
}

class CarouselExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Carousel(
            height: 350.0,
            width: 350,
            initialPage: 3,
            allowWrap: false,
            type: Types.slideSwiper,
            onCarouselTap: (i) {
              print("onTap $i");
            },
            indicatorType: IndicatorTypes.bar,
            arrowColor: Colors.black,
            axis: Axis.horizontal,
            showArrow: true,
            children: List.generate(
                7,
                (i) => Center(
                      child:
                          Container(color: Colors.red.withOpacity((i + 1) / 7)),
                    ))),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_multi_carousel: ^1.0.3

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_multi_carousel/carousel.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/src/carousel/carousel.dart. (-0.50 points)

Analysis of lib/src/carousel/carousel.dart reported 1 hint:

line 17 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: Carousel.updatePositionCallBack, Carousel.updateIndicator, Carousel.controller, Carousel.currentPage, Carousel.key

Fix lib/src/carousel/multi_axis_carousel.dart. (-0.50 points)

Analysis of lib/src/carousel/multi_axis_carousel.dart reported 1 hint:

line 4 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: MultiAxisCarouselState.currentPage, MultiAxisCarouselState.initial

Fix lib/src/carousel/rotatingcarousel.dart. (-0.50 points)

Analysis of lib/src/carousel/rotatingcarousel.dart reported 1 hint:

line 4 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: RotatingCarouselState.currentPage, RotatingCarouselState.initial

Fix additional 5 files with analysis or formatting issues. (-2.50 points)

Additional issues in the following files:

  • lib/src/carousel/simple_carousel.dart (1 hint)
  • lib/src/carousel/slide_swipe.dart (1 hint)
  • lib/src/carousel/x_rotating_carousel.dart (1 hint)
  • lib/src/carousel/zrotatingcarousel.dart (1 hint)
  • lib/src/indicator/widget/dot_indicator.dart (1 hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
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
flutter_test