stacked_trio_carousel 0.0.3 copy "stacked_trio_carousel: ^0.0.3" to clipboard
stacked_trio_carousel: ^0.0.3 copied to clipboard

A flutter package provides a visually engaging card carousel with a stacked layout of three cards.

Stacked Trio Carousel #

Stacked Trio Carousel is a Flutter package that provides a visually engaging card carousel with a stacked layout of three cards.

Features #

The carousel features one prominent card in the foreground and two cards in the background, making it perfect for showcasing content in a layered and dynamic way. With built-in animations and customizable properties, users can swipe through the cards or enable automatic transitions for a smooth and interactive experience.

Getting Started #

To use this package, add stacked_trio_carousel as a dependency in your pubspec.yaml file. For example:

dependencies:
  stacked_trio_carousel: ^0.0.1

Usage #

Specify the background, and set the width and height of the card. Then, provide the children.

final List _color = [Colors.red, Colors.green, Colors.blue];
@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      title: Text(widget.title),
    ),
    body: Center(
      child: StackedTrioCarousel(
        background: Container(),
        cardHeight: 200,
        cardWidth: 200,
        children: _color
            .map(
              (color) => Container(
                decoration: BoxDecoration(
                  color: color,
                  borderRadius: BorderRadius.circular(25),
                ),
              ),
            )
            .toList(),
      ),
    ),
  );
}

Change the Width and Height #

You can modify the dimensions of the cards by changing the cardHeight and cardWidth properties.

cardHeight: 150,
cardWidth: 150,

Add Padding #

To apply padding to the background cards (horizontal padding only), use the padding property.

padding: const EdgeInsets.symmetric(horizontal: 10),

Change Scale and Minimum Opacity #

The scaleRatio and minimumOpacity properties affect the background cards only.

scaleRatio: 0.2,
minimumOpacity: 0.1,

Change Animation Duration #

You can modify the animation duration and the delay between animations. A hot restart may be required for changes to take effect.

animationDuration: const Duration(milliseconds: 200),
durationBetweenAnimations: const Duration(seconds: 1),

Manual Swiping #

You can also allow manual swiping:

Stop Automatic Animation #

To stop the automatic animation, set isAnimated to false.

isAnimated: false,

If your app includes navigation functionality, you need to provide a RouteObserver to ensure the carousel behaves correctly when navigating between screens. Without this, the carousel might still be visible after navigation.

Steps to Add RouteObserver:

  1. Define the RouteObserver as a top-level variable and assign it to your MaterialApp:
final RouteObserver routeObserver = RouteObserver();

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: [routeObserver],
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Stacked Trio Carousel'),
    );
  }
}
  1. Pass the RouteObserver to the StackedTrioCarousel widget:
routeObserver: routeObserver,
  1. Perform a hot restart of the application.

Example #

For a full example, check out the example page.

20
likes
0
points
516
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter package provides a visually engaging card carousel with a stacked layout of three cards.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on stacked_trio_carousel