Search packages, repositories and app categories

draggable_carousel_slider cover
Package detailsv0.0.1

draggable_carousel_slider

A draggable carousel slider widget, support loop and custom child widget.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
42
Likes
25
Pub points
140

Install package

flutter pub add draggable_carousel_slider

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter widget that provides a draggable carousel slider with support for looping and custom child widgets. It enables smooth horizontal scrolling with intuitive drag gestures, ideal for displaying images, cards, or any custom content in a visually engaging way. The slider supports infinite loops, making it suitable for continuous content presentation. Compatible across all major platforms including Android, iOS, Web, macOS, Windows, and Linux, ensuring consistent behavior everywhere. Perfect for apps needing interactive, swipeable content displays.

Use cases

  • Displaying image galleries
  • Creating product carousels
  • Building interactive onboarding screens
  • Presenting featured content
  • Implementing swipeable card interfaces

Key features

  • Draggable gesture support
  • Looping mode
  • Customizable child widgets
  • Cross-platform compatibility
  • Smooth animations
  • Responsive design

Suitable for

  • Mobile app developers
  • Web application creators
  • Interactive UI designers
  • E-commerce app builders
  • Content-rich applications

Considerations

  • Requires careful handling of large datasets
  • May impact performance with heavy child widgets
  • Needs testing on all target platforms
  • Limited built-in styling options
  • Not optimized for vertical scrolling

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Draggable Carousel Slider

Draggable Carousel Slider is a Flutter package that provides a customizable carousel slider widget with draggable functionality. It allows users to easily create interactive carousel sliders where items can be dragged.

Features

  • Draggable functionality: Items in the carousel slider can be dragged horizontally, providing an interactive user experience.
  • Looping option: The carousel slider supports looping through items, allowing seamless navigation from the last item back to the first.
  • Responsive design: The package includes features for handling various screen sizes and orientations, ensuring a consistent user experience across different devices.
  • Custom child widget: Users can supply their own custom widgets as carousel items, enabling a wide range of design possibilities.

Getting started

To start using the Draggable Carousel Slider package, you can simply add the package to your pubspec.yaml file and import it into your Flutter project.

dependencies:
  ...
  draggable_carousel_slider:

Usage

import 'package:draggable_carousel_slider/draggable_carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppPageState();
}

class _MyAppPageState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Widget _image(
    String path,
    double width,
    double height, [
    bool shimmer = false,
  ]) =>
      ClipRRect(
        borderRadius: BorderRadius.circular(16),
        child: Image.network(
          path,
          width: width,
          height: height,
          fit: BoxFit.cover,
          loadingBuilder: (
            BuildContext context,
            Widget child,
            ImageChunkEvent? loadingProgress,
          ) => AnimatedCrossFade(
              firstChild: child,
              secondChild: Shimmer.fromColors(
                baseColor: Colors.grey.shade400,
                highlightColor: Colors.grey.shade700,
                enabled: true,
                period: const Duration(seconds: 2),
                child: Container(
                  width: width,
                  height: height,
                  color: Colors.black,
                ),
              ),
              crossFadeState: shimmer ||
                      ((child as Semantics).child as RawImage).image == null
                  ? CrossFadeState.showSecond
                  : CrossFadeState.showFirst,
              duration: const Duration(milliseconds: 300),
            ),
        ),
      );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
        ),
        useMaterial3: true,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: Center(
              child: DraggableSlider(
                loop: true,
                children: [
                  _image('https://picsum.photos/id/230/600/600', 300, 300),
                  _image(
                      'https://picsum.photos/id/431/600/600', 300, 300, true),
                  _image('https://picsum.photos/id/232/600/600', 300, 300),
                  _image('https://picsum.photos/id/433/600/600', 300, 300),
                  _image('https://picsum.photos/id/234/600/600', 300, 300),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.