搜索插件、代码仓与 APP 分类

swipe_image_gallery 封面
插件详情v0.11.0

swipe_image_gallery

一个可滚动、可通过滑动关闭、可缩放的画廊,您可以在其上添加动态叠加层。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.1万
喜欢数
101
Pub 分数
160

安装插件

flutter pub add swipe_image_gallery

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Swipe Image Gallery 是一个 Flutter 包,可让开发者创建具有滑动关闭、缩放和动态叠加功能的交互式图像画廊。它支持 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台。该画廊允许用户滚动浏览图片,通过滑动来关闭图片,并可放大/缩小以进行详细查看。开发者可以使用动态叠加(如文本或图标)来自定义画廊。非常适合用于照片分享应用、产品展示或任何需要直观图像导航的应用。

适合场景

  • 照片分享应用
  • 产品图片查看器
  • 互动叙事
  • 图像审核工作流程
  • 数字专辑展示

主要特点

  • 滑动关闭功能
  • 可缩放的图像
  • 动态叠加支持
  • 跨平台兼容性
  • 可自定义手势控制
  • 流畅的滚动体验

适合对象

  • 移动和网页图像画廊
  • 需要交互式图像关闭的应用程序
  • 寻求可自定义图像 UI 的开发者
  • 需要缩放和滑动手势的项目
  • 以用户体验为中心的可视化应用

使用建议

  • 可能需要对大型图像集进行性能优化
  • 叠加定位可能需要仔细的布局管理
  • 与其他小部件可能存在手势冲突
  • 有限的内置动画自定义
  • 最适合每画廊中等数量的图像

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Swipe Image Gallery

Pub Version

A scrollable, dismissable by swiping, zoomable gallery on which you can add a dynamic overlay. While it is intended for an image gallery different types of widgets can also be used.

Installation

Add swipe_image_gallery as a dependency in your pubspec.yaml file.

Usage

With a List of Image Widgets
final assets = const [
  Image(image: AssetImage('assets/1.jpeg')),
  Image(image: AssetImage('assets/2.jpeg')),
  Image(image: AssetImage('assets/3.jpeg')),
  Image(image: AssetImage('assets/4.jpeg')),
];

...

SwipeImageGallery(
  context: context,
  children: assets,
).show();

Image Widgets

With a List of Widgets
final widgets = [
  Container(
    color: Colors.white,
    child: Center(
      child: Text('First Page', style: TextStyle(fontSize: 24.0)),
    ),
  ),
  Container(
    color: Colors.grey,
    child: Center(
      child: Text('Second Page', style: TextStyle(fontSize: 24.0)),
    ),
  ),
];

...

SwipeImageGallery(
  context: context,
  children: widgets,
).show();

Widgets

Using Builder
final urls = [
  'https://via.placeholder.com/400',
  'https://via.placeholder.com/800',
  'https://via.placeholder.com/900x350',
  'https://via.placeholder.com/1000',
  'https://via.placeholder.com/100',
];

...

SwipeImageGallery(
  context: context,
  itemBuilder: (context, index) {
    return Image.network(urls[index]);
  },
  itemCount: urls.length,
).show();

Add an Overlay

You can find the OverlayExample widget here.

  StreamController<Widget> overlayController =
      StreamController<Widget>.broadcast();

  @override
  void dispose() {
    overlayController.close();
    super.dispose();
  }

  ...

  SwipeImageGallery(
    context: context,
    children: remoteImages,
    onSwipe: (index) {
      overlayController.add(OverlayExample(
        title: '${index + 1}/${remoteImages.length}',
      ));
    },
    overlayController: overlayController,
    initialOverlay: OverlayExample(
      title: '1/${remoteImages.length}',
    ),
  ).show();

overlay

Hero Animation
final heroProperties = [
  ImageGalleryHeroProperties(tag: 'imageId1'),
  ImageGalleryHeroProperties(tag: 'imageId2'),
];

final assets = const [
  Image(image: AssetImage('assets/1.jpeg')),
  Image(image: AssetImage('assets/2.jpeg')),
];

...

Row(
  children: [
    Expanded(
      child: InkWell(
        onTap: () => SwipeImageGallery(
          context: context,
          children: assets,
          heroProperties: heroProperties,
        ).show(),
        child: Hero(
          tag: 'imageId1',
          child: Image(
            image: AssetImage('assets/1.jpeg'),
          ),
        ),
      ),
    ),
    Expanded(
      child: InkWell(
        onTap: () => SwipeImageGallery(
          context: context,
          children: assets,
          initialIndex: 1,
          heroProperties: heroProperties,
        ).show(),
        child: Hero(
          tag: 'imageId2',
          child: Image(
            image: AssetImage('assets/2.jpeg'),
          ),
        ),
      ),
    ),
  ],
),

hero

For more detailed examples you can check out the example project.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。