搜尋套件、儲存庫與 APP 分類

gallery_image_viewer 封面
套件詳情v1.2.0

gallery_image_viewer

一個簡單的圖像查看器,支援捏合縮放、多圖瀏覽、畫廊圖片以及內建全螢幕對話框支援。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
726
喜歡數
32
Pub 分數
150

安裝套件

flutter pub add gallery_image_viewer

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,提供直覺式的影像檢視器,支援雙指縮放、多圖導航與相簿風格瀏覽。內建全螢幕對話方塊功能,非常適合在跨平台環境中以無縫、使用者友善的方式顯示影像。設計簡潔且效能優異,可輕鬆整合至需要強大影像檢視功能的應用程式中,無需進行大量自訂實作。此套件支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 顯示圖像畫廊
  • 查看高解析度圖像並縮放
  • 全螢幕圖片瀏覽
  • 在照片應用中整合圖像查看器
  • 增強媒體密集型應用中的使用者體驗

主要特色

  • 縮放手勢支援
  • 多圖像導航
  • 內建全螢幕對話方塊
  • 跨平台相容性
  • 簡單整合,設定最少
  • 畫廊式圖片瀏覽

適合對象

  • 照片分享應用
  • 電子商務產品圖片查看器
  • 旅行或投資組合應用
  • 教育或文件應用
  • 需要互動式圖像探索的應用程式

使用建議

  • 需要正確的圖像資源管理
  • 可能需要額外的樣式來自訂UI
  • 性能取決於影像大小和數量
  • 僅限圖像內容
  • 不適用於影片播放

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

GalleryImageViewer

An easy way to display images in a full-screen dialog, including pinch & zoom.

Pub Tests license

Easy Image Viewer Demo

Features

  • Show a single image or a swipeable list of images
  • Use pinch & zoom to zoom in and out of images
  • Optionally allow "swipe down to dismiss" by passing in swipeDismissible: true
  • No dependencies besides Flutter
  • Callbacks for onPageChanged and onViewerDismissed

Usage

Show a Gallery image:

final List<ImageProvider> _imageProviders = [
    Image.network("https://picsum.photos/id/237/200/300").image,
    Image.network("https://picsum.photos/seed/picsum/200/300").image,
    Image.network("https://picsum.photos/200/300?grayscale").image,
    Image.network("https://picsum.photos/200/300").image,
    Image.network("https://picsum.photos/200/300?grayscale").image
  ];
GalleryImageView(
  listImage: _imageProviders,
  width: 200,
  height: 200,
  imageDecoration: BoxDecoration(border: Border.all(color: Colors.white)),
),

Show a single image:

final imageProvider = Image.network("https://picsum.photos/id/1001/5616/3744").image;
showImageViewer(context, imageProvider, onViewerDismissed: () {
  print("dismissed");
});

Show a bunch of images:

MultiImageProvider multiImageProvider = MultiImageProvider([
  Image.network("https://picsum.photos/id/1001/5616/3744").image,
  Image.network("https://picsum.photos/id/1003/1181/1772").image,
  Image.network("https://picsum.photos/id/1004/5616/3744").image,
  Image.network("https://picsum.photos/id/1005/5760/3840").image
]);

showImageViewerPager(context, multiImageProvider, onPageChanged: (page) {
  print("page changed to $page");
}, onViewerDismissed: (page) {
  print("dismissed while on page $page");
});

Usually you'll want to implement your own EasyImageProvider. Suppose you have a list of Products, each of which has an imagePath property with the path to a local image file. You could create an EasyImageProvider that takes a list of Products like this:

class ProductsImageProvider extends EasyImageProvider {

  final List<Product> products;
  final int initialIndex;

  ProductsImageProvider({ required this.products, this.initialIndex = 0 });

  @override
  ImageProvider<Object> imageBuilder(BuildContext context, int index) {
    String? localImagePath = products[index].imagePath;
    File? imageFile;

    if (localImagePath != null) {
      imageFile = File(localImagePath);
    }

    ImageProvider imageProvider = imageFile != null ? FileImage(imageFile) : AssetImage("assets/images/product_placeholder.jpg") as ImageProvider;

    return imageProvider;
  }

  @override
  int get imageCount => products.length;
}

You could then use it like this:

ProductsImageProvider productsImageProvider = ProductsImageProvider(products: products);

showImageViewerPager(context, productsImageProvider, onPageChanged: (page) {
  print("page changed to $page");
}, onViewerDismissed: (page) {
  print("dismissed while on page $page");
});

Credits

GalleryImageViewer is custom from EasyImageViewer. EasyImageViewer is a project by TSG, a full-service digital agency taking software from concept to launch. Our powerhouse team of designers and engineers build iOS, Android, and web apps across many industries.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。