Flutter Carousel Media Slider

A Flutter package for creating a carousel media slider widget. It supports both images and videos.

Configuration

Android

Add the following to your build.gradle file located in android/app/build.gradle.

compileSdkVersion 33
minSdkVersion 21
targetSdkVersion 33

iOS

No configuration required.

Required fields:

  • MediaName
  • MediaUrl
  • MediaType
  • carouselImageSource

Step 1: Create a list of CarouselMedia


List<CarouselMedia> media = [
  CarouselMedia(
    mediaName: 'Image 1',
    mediaUrl:
    'https://images.pexels.com/photos/1172253/pexels-photo-1172253.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
    mediaType: CarouselMediaType.image,
    carouselImageSource: CarouselImageSource.network,
  ),
  CarouselMedia(
    mediaName: 'Video 1',
    mediaUrl: 'https://www.youtube.com/watch?v=4AoFA19gbLo',
    mediaType: CarouselMediaType.video,
    carouselImageSource: CarouselImageSource.network,
  ),
  CarouselMedia(
    mediaName: 'Image 2',
    mediaUrl:
    'https://media.istockphoto.com/photos/mountain-landscape-picture-id517188688?k=20&m=517188688&s=612x612&w=0&h=i38qBm2P-6V4vZVEaMy_TaTEaoCMkYhvLCysE7yJQ5Q=',
    mediaType: CarouselMediaType.image,
    carouselImageSource: CarouselImageSource.network,
  ),
  CarouselMedia(
    mediaName: 'Image 5',
    mediaUrl:
    'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4',
    mediaType: CarouselMediaType.video,
    carouselImageSource: CarouselImageSource.network,
  )
];
FlutterCarouselMediaSlider(
    carouselMediaList: media,
    placeholder: const Center(
    child: Text('Loading...'),
    ),
    onPageChanged: (index) {
    debugPrint('Page Changed: $index');
    },
),

Raise an issue if you find any bugs or if you have any suggestions email us at agkc-flutter-pub.