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

pdf_thumbnail 封面
插件详情v0.1.6+1

pdf_thumbnail

PDF 文件的缩略图查看器。支持 Android 和 iOS。只需添加小部件并提供文件路径即可。

AndroidiOSWebmacOSWindows
近 30 天下载
5
喜欢数
51
Pub 分数
150

安装插件

flutter pub add pdf_thumbnail

插件介绍

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

一个用于在 Android、iOS、Web、macOS 和 Windows 上显示 PDF 缩略图的 Flutter 包。该包通过简单地添加一个组件并提供文件路径,使开发者能够轻松将缩略图查看器集成到其应用中。该包轻量级,旨在实现 PDF 页面预览的无缝渲染,无需复杂的设置。非常适合文档管理应用或任何需要快速视觉访问 PDF 内容的应用。

适合场景

  • 移动应用中的文档预览
  • PDF画廊界面
  • 快速文件浏览
  • 电子学习平台
  • 数字图书馆应用

主要特点

  • 跨平台支持
  • 简单小部件集成
  • 文件路径输入
  • 轻量级渲染
  • 响应式缩略图布局

适合对象

  • 开发文档查看器的开发者
  • 需要 PDF 导航的应用程序
  • 教育或企业软件
  • 以用户界面为重点的PDF应用程序

使用建议

  • 需要有效的PDF文件路径
  • 仅限缩略图显示
  • 无交互式PDF功能
  • 未针对大PDF文件进行优化
  • 取决于底层平台的渲染

原始 README

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

Pdf Thumbnail

style: very good analysis Powered by Mason License: MIT

Thumbnail viewer for pdfs

Installation 💻

❗ In order to start using Pdf Thumbnail you must have the Flutter SDK installed on your machine.

Add pdf_thumbnail to your pubspec.yaml:

dependencies:
  pdf_thumbnail:

Install it:

flutter packages get

Example ✍️

 return Stack(
              children: [
                SizedBox(
                  height: MediaQuery.of(context).size.height,
                  width: MediaQuery.of(context).size.width,
                  child: PdfViewer(
                    filePath: snapshot.data!.path,
                  ),
                ),
                if (showThumbnail)
                  Positioned(
                    bottom: 0,
                    width: MediaQuery.of(context).size.width,
                    // Here's the thumbnail widget.
                    child: PdfThumbnail.fromFile(snapshot.data!.path),
                  ),
              ],
            );

There is a detailed example app in the repo, but I've deleted iOS and Android folders. Simple go to example folder, and run flutter create . inside the folder to add missing native files for the example app.

Demo

gif

Caching ⏲

I left caching part unopinionated to keep the package simple. Just create your own class from ImageThumbnailCacher and implement the read/write methods. Holding images as Uint8List, so Map<int, Uint8List> is what's need to be written to and read from the cache. It maps page numbers to the images.

class ThumbnailCacher implements ImageThumbnailCacher {
  @override
  Future<PageToImage?> read(String id) async {
    return api.localStorage.readThumbnails(id);
  }

  @override
  Future<bool> write({required String id, required PageToImage map}) {
    return api.localStorage.writeThumbnails(id: id, map: map);
  }
}

I'm using Hive to cache.

Roadmap 🗺️

  • [X] Customization for colors, decoration etc.
  • [X] onTap callback and page number.
  • [X] Caching.
  • [ ] Different layouts and scroll axises.
  • [ ] Lazy loading.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。