flutter_image_slideshow
A simple image slideshow widget.
Mainly intended for image widget, but other widgets can also be used.
Getting Started
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:
flutter:
sdk:
flutter_image_slideshow: any
In your library add the following import:
import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
Usage
These are The ImageSlideshow properties.
List<Widget> children
double width
double height
int initialPage
Color indicatorColor
Color indicatorBackgroundColor
ValueChanged<int> onPageChanged
int autoPlayInterval
bool isLoop
double indicatorRadius
bool disableUserScrolling
Example
Create the ImageSlideshow widget.
And pass the parameters.
import 'package:flutter/material.dart';
import 'package:flutter_image_slideshow_test/flutter_image_slideshow.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Demo'),
),
body: ImageSlideshow(
width: double.infinity,
height: 200,
initialPage: 0,
indicatorColor: Colors.blue,
indicatorBackgroundColor: Colors.grey,
children: [
Image.asset(
'images/sample_image_1.jpg',
fit: BoxFit.cover,
),
Image.asset(
'images/sample_image_2.jpg',
fit: BoxFit.cover,
),
Image.asset(
'images/sample_image_3.jpg',
fit: BoxFit.cover,
),
],
onPageChanged: (value) {
print('Page changed: $value');
},
autoPlayInterval: 3000,
isLoop: true,
),
),
);
}
}