一个轻量级的 Flutter 小部件,用于创建带有平滑过渡效果的图像幻灯片。主要设计用于显示图片,同时也支持在幻灯片中使用自定义小部件。非常适合用于画廊、产品展示或介绍屏幕。该包跨平台,可在 Android、iOS、Web、macOS、Windows 和 Linux 上无缝运行。通过单一依赖项即可轻松集成,并提供简洁的 API 来管理幻灯片和动画。
适合场景
图像画廊
产品轮播
入门屏幕
数字标牌
演示接口
主要特点
平滑的滑动过渡
对自定义控件的支持
跨平台兼容性
简单设置,使用 pub add
可配置的自动播放和持续时间
适合对象
开发视觉内容显示的开发者
需要交互式图像演示的应用程序
项目需要最少的设置即可进行幻灯片演示
使用建议
可能需要对大型图像集进行优化
复杂动画的自定义选项有限
不适合高性能视频幻灯片
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
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:
/// The widgets to display in the [ImageSlideshow].////// Mainly intended for image widget, but other widgets can also be used.List<Widget> children
/// Width of the [ImageSlideshow].double width
/// Height of the [ImageSlideshow].double height
/// The page to show when first creating the [ImageSlideshow].int initialPage
/// The color to paint the indicator.Color indicatorColor
/// The color to paint behind th indicator.Color indicatorBackgroundColor
/// Called whenever the page in the center of the viewport changes.ValueChanged<int> onPageChanged
/// Auto scroll interval.////// Do not auto scroll with null or 0.int autoPlayInterval
/// Loops back to first slide.bool isLoop
/// Radius of circle indicator.double indicatorRadius
/// Disable page changes by the user.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';
voidmain() {
runApp(MyApp());
}
classMyAppextendsStatelessWidget{
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Demo'),
),
body: ImageSlideshow(
/// Width of the [ImageSlideshow].
width: double.infinity,
/// Height of the [ImageSlideshow].
height: 200,
/// The page to show when first creating the [ImageSlideshow].
initialPage: 0,
/// The color to paint the indicator.
indicatorColor: Colors.blue,
/// The color to paint behind th indicator.
indicatorBackgroundColor: Colors.grey,
/// The widgets to display in the [ImageSlideshow]./// Add the sample image file into the images folder
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,
),
],
/// Called whenever the page in the center of the viewport changes.
onPageChanged: (value) {
print('Page changed: $value');
},
/// Auto scroll interval./// Do not auto scroll with null or 0.
autoPlayInterval: 3000,
/// Loops back to first slide.
isLoop: true,
),
),
);
}
}