A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

Overview

flutter_carousel_widget

A customizable carousel slider widget in Flutter.

Features

  • Infinite Scroll
  • Custom Child Widget
  • Auto Play
  • Horizontal and Vertical Alignment
  • Customization
  • Many more features are coming soon

Installation

Add flutter_carousel_widget as a dependency in your pubspec.yaml file:

dependencies:
flutter_carousel_widget: ^0.0.1

And import it:

import 'package:flutter_carousel_widget/flutter_carousel_widget.dart';

Usage

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

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

Option Customization

FlutterCarousel(
   items: items,
   options: CarouselOptions(
      height: 400,
      aspectRatio: 16/9,
      viewportFraction: 0.8,
      initialPage: 0,
      enableInfiniteScroll: true,
      reverse: false,
      autoPlay: true,
      autoPlayInterval: Duration(seconds: 3),
      autoPlayAnimationDuration: Duration(milliseconds: 800),
      autoPlayCurve: Curves.fastOutSlowIn,
      enlargeCenterPage: true,
      onPageChanged: callbackFunction,
      scrollDirection: Axis.horizontal,
   )
 )

Build item widgets on demand

This method will save memory by building items once it becomes necessary. This way they won't be built if they're not currently meant to be visible on screen. It can be used to build different child item widgets related to content or by item index.

FlutterCarousel.builder(
  itemCount: 15,
  itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
    Container(
      child: Text(itemIndex.toString()),
    ),
)

Carousel controller

In order to manually control the pageview's position, you can create your own CarouselController, and pass it to CarouselSlider. Then you can use the CarouselController instance to manipulate the position.

class CarouselDemo extends StatelessWidget {
  CarouselController buttonCarouselController = CarouselController();

 @override
  Widget build(BuildContext context) => Column(
    children: <Widget>[
      FlutterCarousel(
        items: child,
        carouselController: buttonCarouselController,
        options: CarouselOptions(
          autoPlay: false,
          enlargeCenterPage: true,
          viewportFraction: 0.9,
          aspectRatio: 2.0,
          initialPage: 2,
        ),
      ),
      RaisedButton(
        onPressed: () => buttonCarouselController.nextPage(
            duration: Duration(milliseconds: 300), curve: Curves.linear),
        child: Text('→'),
      )
    ]
  );
}

CarouselController methods

.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.

Screenshots

Basic Flutter Carousel:

simple

Enlarge Center Widget Flutter Carousel:

simple

Fullscreen Flutter Carousel:

simple

Manually Controlled Flutter Carousel:

simple

Flutter Carousel with indicator:

simple

Flutter Carousel with multiple item in one widget:

simple

Credits

This package is initially inspired from carousel_slider package. Thanks serenader.me for the package. I am extended this package with some extra toppings and new features.

Connect With Me

nixrajput | Website

nixrajput | GitHub

nixrajput | Instagram

nixrajput | Facebook

nixrajput | Twitter

nixrajput | LinkedIn

Comments
  • Unhandled Exception: Null check operator used on a null value

    Unhandled Exception: Null check operator used on a null value

    I get an error because state is null in the most recent version.

    Any ideas what I'm missing?

    I'll post more code if needed.

    flutter_carousel_controller.dart

      Future<void> nextPage(
          {Duration? duration = const Duration(milliseconds: 300),
          Curve? curve = Curves.linear}) async {
        final isNeedResetTimer = _state!.options.pauseAutoPlayOnManualNavigate;
        if (isNeedResetTimer) {
          _state!.onResetTimer();
        }
        _setModeController();
        await _state!.pageController!.nextPage(duration: duration!, curve: curve!);
        if (isNeedResetTimer) {
          _state!.onResumeTimer();
        }
      }
    
    opened by bradintheusa 9
  • Overlapping parent

    Overlapping parent

    Hi

    The carousel widget is great and works really well with good options. but the basic constraining to the parent eg a Card, doesn't seem to work?

    image

    eg as shown here the carousel is overlapping the edges of the card shown in red lines.

    any ideas?

    thanks

    opened by cloudygeek 7
  •  Page value is only available after content dimensions are established.)

    Page value is only available after content dimensions are established.)

    After enabling enlargerPage to true then the error message appeared Exception has occurred. _AssertionError ('package:flutter/src/widgets/page_view.dart': Failed assertion: line 402 pos 7: '!hasPixels || hasContentDimensions': Page value is only available after content dimensions are established.)

    This was happened to flutter_carousel_slider, I don't have an idea how to fix this, I've tried to resolve it did not succeed

    opened by aisivan36 4
  • Add option for dynamic height based on the child's height

    Add option for dynamic height based on the child's height

    Is it possible to add an option for dynamic height? in my use case, the children widget's height isn't fixed, there's possibility that one children's height isn't the same with the other children's height.

    image within that card, there's a dynamically loaded widget, sometimes loaded, sometimes not. because the current implementation forced children's height to be the same as the height set on the option, it makes a blank space within the card. would be great if the carousel doesn't force the height at least. and even better if there's option for dynamic height.

    enhancement question 
    opened by alyyasser 0
  • Suggest an idea for this project

    Suggest an idea for this project

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is.

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement 
    opened by nixrajput 0
Owner
NIKHIL RAJPUT
Proud Indian | Student | Full Stack Developer | Freelancer
NIKHIL RAJPUT
Flutter custom carousel slider - A carousel slider widget,support custom decoration suitable for news and blog

flutter_custom_carousel_slider A carousel slider Flutter widget, supports custom

Emre 40 Dec 29, 2022
MindInventory 15 Sep 5, 2022
Card-slider-flutter - Implementation of swipeable image cards with dot indicators

card_slider A new Flutter project. Getting Started This project is a starting po

Ryan Egbejule-jalla 1 Sep 17, 2022
Custom dropdown widget allows to add highly customizable widget in your projects with proper open and close animations and also comes with form required validation.

Custom Dropdown Custom Dropdown package lets you add customizable animated dropdown widget. Features Lots of properties to use and customize dropdown

Abdullah Chauhan 22 Dec 29, 2022
A radio button widget for flutter that supports custom builders and a variable number of animations.

custom_radio An animatable radio button that can be customized to the max. I found it strange that flutter only provides two radio widgets: Radio and

Conrad Heidebrecht 37 Dec 28, 2022
A flutter widget which renders its child outside the original widget hierarchy.

overlay_container A flutter widget which renders its child outside the original widget hierarchy. Demo. This demo is present as an example here. You c

Mustansir Zia 30 Jun 10, 2022
This widget automatically scrolls the custom child widget to an infinite loop.

Scroll Loop Auto Scroll This widget automatically scrolls the custom child widget to an infinite loop. Example Features Infinite Auto Scroll Custom ch

Ashish Raturi 9 Dec 12, 2022
Practice building basic animations in apps along with managing app state by BLoC State Management, Flutter Slider.

Practice building basic animations in apps along with managing app state by BLoC State Management including: Cubit & Animation Widget, Flutter Slider.

TAD 1 Jun 8, 2022
A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs when current is overscroll, and set scroll direction and cache extent.

extended_tabs Language: English | 中文简体 A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs whe

FlutterCandies 185 Dec 13, 2022
A customizable circular slider for Flutter.

flutter_circular_slider A customizable circular slider for Flutter. Getting Started Installation Basic Usage Constructor Use Cases Installation Add fl

David 193 Nov 14, 2022
Advanced & beautiful animations inspired by animate_do and Animate.css, every animation is a widget that contains default but customizable values 💙

animate_it An animation package inspired by animate_do and Animate.css. Since the original animate_do is not being maintained, I have decided to creat

Luke Moody 3 Oct 1, 2022
This is a view pager provides carousel effect and dismissal animation when page was removed.

This is a view pager provides carousel effect and dismissal animation when page was removed. Features Carousel effect Horizontal Vertical Dismissal an

Zhe-Yi, Zhu 4 Dec 22, 2022
A carousel package in flutter with various configuration options

Flutter_Carosel A simple Carousel Widget with multiple configuration option. ... dependencies: ... flutter_multi_carousel: ^1.0.0 ... And install it

GeekyAnts 67 Oct 2, 2022
Sample Flutter Drawing App which allows the user to draw onto the canvas along with color picker and brush thickness slider.

DrawApp Sample Flutter Drawing App which allows the user to draw onto the canvas along with color picker and brush thickness slider. All code free to

Jake Gough 226 Nov 3, 2022
Add beautiful and trending tab indicators directly to your default Flutter TabBar

Add beautiful and trending tab indicators directly to your default Flutter TabBar. Features ?? Supports Android, iOS, Web Can be directly added to the

Adar 51 Dec 23, 2022
Selectable Circle where colors can be customized and a child widget can be defined

selectable_circle A Flutter package for an Circle that can be Selected with animation. How to use SelectableCircle( width: 80.0, onSelected: (

null 11 Sep 29, 2021
A package that offers various page indicators inlcuding a Flutter implementation of the Ink Page Indicator

A package that offers various page indicators inlcuding a Flutter implementation of the Ink Page Indicator. See below for more examples.

null 50 Jan 6, 2022
A ListView widget capable of pinning a child to the top of the list.

PinnableListView A Flutter ListView widget that allows pinning a ListView child to the top of the list. Demo Getting Started Define the list PinCont

Jan Hrastnik 2 May 17, 2020
Access app version and git informations from auto-generated and configurable widgets

This is a proof of concept and WIP Feedback and ideas welcome !! Access your pubspec and git commit informations like versions and commit status from

Robert Felker 15 Jul 7, 2021