Curved Carousel Plus

A beautiful curved carousel widget for Flutter that displays items with the center item prominently focused and side items partially visible below it, creating an elegant 3D-like effect.

Features

  • 🎨 Curved Layout: Center item is prominently displayed at the top, with side items positioned below it
  • 🎯 Smooth Animations: Smooth transitions between items
  • ⚙️ Highly Customizable: Adjust curve height, item spacing, size, and more
  • 🔄 Auto-play Support: Optional auto-play functionality
  • 📱 Responsive: Works on all screen sizes
  • 🎭 Visual Effects: Scale and opacity effects for non-center items
  • 🌟 Focus Effect: Center item stands out with full size and opacity, side items fade and scale down

Installation

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

dependencies:
  curved_carousel_plus: ^1.0.0

Then run:

flutter pub get

Usage

Basic Example

import 'package:curved_carousel_plus/curved_carousel_plus.dart';

CurvedCarousel(
  items: [
    Container(color: Colors.red, child: Center(child: Text('Item 1'))),
    Container(color: Colors.blue, child: Center(child: Text('Item 2'))),
    Container(color: Colors.green, child: Center(child: Text('Item 3'))),
  ],
)

Advanced Example

CurvedCarousel(
  items: myWidgets,
  curveHeight: 120.0,           // Height of the curve
  itemSpacing: 30.0,            // Spacing between items
  itemHeight: 250.0,            // Height of each item
  itemWidth: 180.0,             // Width of each item
  initialIndex: 2,              // Start at index 2
  autoPlay: true,               // Enable auto-play
  autoPlayDuration: Duration(seconds: 4),
  animationDuration: Duration(milliseconds: 400),
  scaleFactor: 0.85,            // Scale for non-center items
  opacityFactor: 0.7,           // Opacity for non-center items
  onItemTap: (index) {
    print('Item $index tapped');
  },
  onIndexChanged: (index) {
    print('Current index: $index');
  },
)

Parameters

Parameter Type Default Description
items List<Widget> Required List of widgets to display in the carousel
curveHeight double 100.0 Height of the curve (how much items curve upward)
itemSpacing double 20.0 Horizontal spacing between items
itemHeight double 200.0 Height of each carousel item
itemWidth double 150.0 Width of each carousel item
initialIndex int 0 Initial index to display
autoPlay bool false Whether to enable auto-play
autoPlayDuration Duration 3 seconds Duration between auto-play transitions
animationDuration Duration 300ms Animation duration for transitions
onItemTap ValueChanged<int>? null Callback when an item is tapped
onIndexChanged ValueChanged<int>? null Callback when the current index changes
scaleFactor double 0.8 Scale factor for items that are not in the center
opacityFactor double 0.6 Opacity for items that are not in the center
viewportFraction double 0.7 How much of the screen each item takes (0.0-1.0)

Example App

A comprehensive example app is included in the example/ directory demonstrating:

  • Basic Carousel: Simple carousel with default settings
  • Auto-Play Carousel: Carousel with automatic scrolling
  • Custom Styling: Custom curve height, spacing, scale, and opacity
  • Image Carousel: Displaying image-like content with emojis
  • Card Carousel: Card-style items for pricing plans or features

To run the example:

cd example
flutter run

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Libraries

A beautiful curved carousel widget for Flutter.
main