Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • What is Software Development
  • SDLC
  • Models
  • Agile Software Development
  • Software Developer
  • SDE Roadmap
  • SDE Interview Guide
  • SDE SHEET
  • Projects
  • SDE Companies
  • Types of Software Development
  • Learn Product Management
  • Software Engineering Tutorial
  • Software Testing Tutorial
  • Project Management Tutorial
  • Agile Methodology
  • Selenium Basics
Open In App
Next Article:
CarouselView class in Flutter
Next article icon

CarouselView class in Flutter

Last Updated : 01 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A CarouselView widget in Flutter is an advanced widget that helps developers design a list of widgets where only one item is visible at a time, similar to a carousel. It can be implemented to cycle through images, items, product cards, or content sliders, among others. In this article, more focus is given to the properties and possible ways of using the CarouselView class, as well as the impact that defining specific properties would have on the carousel.

Constructor of CarouselView

The CarouselView constructor allows you to create a material design carousel with several customizable properties:

CarouselView CarouselView({
Key? key,
EdgeInsets? padding,
Color? backgroundColor,
double? elevation,
ShapeBorder? shape,
WidgetStateProperty<Color?>? overlayColor,
bool itemSnapping = false,
double shrinkExtent = 0.0,
CarouselController? controller,
Axis scrollDirection = Axis.horizontal,
bool reverse = false,
void Function(int)? onTap,
bool enableSplash = true,
required double itemExtent,
required List<Widget> children,
})

Key Properties

Let's explore some of the essential properties of the CarouselView class.

1. backgroundColor

The backgroundColor property defines the background color for each carousel item. Setting this property changes the appearance of each item in the carousel.

Example:

Dart
Center(     child: SizedBox(         height: 200,         child: CarouselView(             backgroundColor: Colors.blueAccent,             itemExtent: 200,                          children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),             ],         ),     ), ), 

Output:

Each item in the carousel will have a blue accent background.

bgcolor


2. elevation

The elevation property sets the z-coordinate of each carousel item, giving it a shadow effect.

Example:

Dart
Center( child: SizedBox(         height: 200,         child: CarouselView(             backgroundColor: Colors.blueAccent,             itemExtent: 200,             elevation: 5.0,             children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),             ],         ),     ), ), 

Output:

Each item will appear elevated with a shadow, making it stand out from the background.

elevation


3. shape

The shape property allows you to customize the shape of each carousel item using ShapeBorder.

Example:

Dart
Center( child: SizedBox(         height: 200,         child: CarouselView(             shape: RoundedRectangleBorder(                 borderRadius: BorderRadius.circular(150),             ),             backgroundColor: Colors.blueAccent,             itemExtent: 200,             children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),             ],         ),     ), ), 

Output:

Each item in the carousel will have rounded corners, giving it a more refined appearance.

shape


4. padding

The padding property defines the space surrounding each carousel item.

Example:

Dart
Center( child: SizedBox(         height: 200,         child: CarouselView(             padding: EdgeInsets.all(8.0),             backgroundColor: Colors.blueAccent,             itemExtent: 200,             elevation: 5.0,             children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),                 Center(child: Text('Item 4')),             ],         ),     ), ), 

Output:

Each item will have padding around it, ensuring that the items are not too close to each other.

padding


5. itemSnapping

The itemSnapping property controls whether the carousel should snap to the next or previous item when scrolling. This is particularly useful when you want the user to focus on one item at a time.

Example:

Dart
Center( child: SizedBox(         height: 200,         child: CarouselView(             itemSnapping: true,             backgroundColor: Colors.blueAccent,             itemExtent: 200,             children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),             ],         ),     ), ), 

Output:

When scrolling, the carousel will automatically snap to the next item, ensuring that each item is centered in the view.

snapping


6. scrollDirection

The scrollDirection property allows you to specify the direction in which the carousel scrolls. By default, it scrolls horizontally.

Example:

Dart
Center( child: SizedBox(         height: 200,         child: CarouselView(             scrollDirection: Axis.vertical,             backgroundColor: Colors.blueAccent,             itemExtent: 200,             children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),             ],         ),     ), ), 

Output:

The carousel will scroll vertically instead of horizontally.

direction


7. reverse

The reverse property determines whether the carousel should scroll in the reverse direction.

Example:

Dart
Center( child: SizedBox(         height: 200,         child: CarouselView(             reverse: true,             backgroundColor: Colors.blueAccent,             itemExtent: 200,             children: [                 Center(child: Text('Item 1')),                 Center(child: Text('Item 2')),                 Center(child: Text('Item 3')),             ],         ),     ), ), 

Output:

The carousel will scroll in the opposite direction, starting from the last item.

7direction


Code Example: Combining Multiple Properties

Here’s a complete example combining several properties to create a more customized carousel:

Dart
Center(     child: SizedBox(         height: 200,         child: CarouselView(             padding: EdgeInsets.symmetric(horizontal: 16.0),             backgroundColor: Colors.white,             elevation: 4.0,             shape: RoundedRectangleBorder(                 borderRadius: BorderRadius.circular(10),             ),             itemSnapping: true,             scrollDirection: Axis.horizontal,             itemExtent: 250,             children: [                 Container(                     color: Colors.red,                     child: Center(child: Text('Item 1')),                 ),                 Container(                     color: Colors.green,                     child: Center(child: Text('Item 2')),                 ),                 Container(                     color: Colors.blue,                     child: Center(child: Text('Item 3')),                 ),             ],         ),     ), ), 

Output:

This example creates a horizontally scrolling carousel with rounded corners, padding, elevation, and snapping behavior. Each item will have a different background color, and the carousel will snap to the nearest item as it scrolls.

final


Conclusion

The CarouselView class in Flutter offers a versatile way to create visually appealing carousels with customizable properties. By adjusting properties like backgroundColor, elevation, shape, and itemSnapping, you can create a carousel that fits the specific needs of your application. The examples provided should give you a good starting point to explore the potential of CarouselView in your Flutter projects.


Next Article
CarouselView class in Flutter

Y

ypathatxp1
Improve
Article Tags :
  • Dart
  • Flutter
  • Android
  • Software Development
  • Flutter
  • Dart-basics
  • Flutter-Basics

Similar Reads

    Flutter - Carousel Slider
    Carousel Slider is one of the most popular image sliders used nowadays in most apps. These carousel sliders are mostly seen on various eCommerce sites such as Amazon, Flipkart, Myntra, and many more. Displaying the images in a slider gives an attractive User Experience. As these sliders are automate
    4 min read
    Flutter - BottomSheet Class
    Bottom Sheet is one of the popular ways to show various options on the screen. This helps the user to switch to a new screen. You will see this bottom sheet in most of the app to add data or add some information such as address or ticket number. In this article, we are going to see how to implement
    7 min read
    Container class in Flutter
    Container class in flutter is a convenience widget that combines common painting, positioning, and sizing of widgets. A Container class can be used to store one or more widgets and position them on the screen according to our convenience. Basically, a container is like a box to store contents. A bas
    8 min read
    FlipCard in Flutter
    flip_card is a component that provides a flip card animation. It could be used for hiding and showing details of a product. A sample video is given below to get an idea about what we are going to do in this article. Installing  Add the dependency into pubspec.yaml file. dependencies: flip_card: ^0.6
    3 min read
    ListView Class in Flutter
    In Flutter, ListView is a scrollable list of widgets arranged linearly. It displays its children sequentially in the scrolling direction, either vertically or horizontally. There are different types of ListViews :ListViewListView.builderListView.separatedListView.customConstructor of ListView Class:
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences