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

GitHub 代码仓binSaed/flutter_cached_pdfview

flutter_cached_pdfview

Flutter 的增强型 PDF 查看器。

flutter_cached_pdfview 项目封面
星标
133
复刻
99
最近推送(UTC)
2026年7月16日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

flutter_cached_pdfview

Awesome Flutter

Pub Version GitHub repo size issues-raw license last-commit stars Dart CI


A package to show Native PDF View for iOS and Android, support Open from a different resource like Path, Asset or Url and Cache it.

📖 Read the case study — how this package is built and maintained — and the step-by-step usage guide by the author.

Support = [ Android , IOS and WEB(soon) ];
  • Open Pdf From Path(local file)
  • Open Pdf From Asset
  • Open Pdf From URl and Cache it
  • Display horizontally or vertically
  • Drag and zoom
  • Double tap for zoom
  • Support password protected pdf
  • Jump to a specific page in the pdf

Setup
iOS

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

iOS (only support> 11.0) you need to add this line in your ios/Podfile

platform :ios, '11.0'

ready-made in the Example

Import it

Now in your Dart code, you can use:

import 'package:flutter_cached_pdfview/flutter_cached_pdfview.dart';

Options

Name Android iOS Default
defaultPage ✅ ✅ 0
onViewCreated ✅ ✅ null
onRender ✅ ✅ null
onPageChanged ✅ ✅ null
onError ✅ ✅ null
onPageError ✅ ❌ null
onLinkHandle ✅ ✅ null
gestureRecognizers ✅ ✅ null
filePath ✅ ✅
fitPolicy ✅ ❌ FitPolicy.WIDTH
enableSwipe ✅ ✅ true
swipeHorizontal ✅ ✅ false
password ✅ ✅ null
nightMode ✅ ❌ false
autoSpacing ✅ ✅ true
pageFling ✅ ✅ true
pageSnap ✅ ❌ true
preventLinkNavigation ✅ ✅ false
bockgroundColor ✅ ✅ null

Controller Options

Name Description Parameters Return
getPageCount Get total page count - Future<int>
getCurrentPage Get current page - Future<int>
setPage Go to/Set page int page Future<bool>

Example

from Asset
       PDF(
        enableSwipe: true,
        swipeHorizontal: true,
        autoSpacing: false,
        pageFling: false,
        backgroundColor: Colors.grey,
        onError: (error) {
          print(error.toString());
        },
        onPageError: (page, error) {
          print('$page: ${error.toString()}');
        },
        onPageChanged: (int page, int total) {
          print('page change: $page/$total');
        },
      ).fromAsset('assets/pdf/file-example.pdf'),

cached From Url
      PDF(
        swipeHorizontal: true,
      ).cachedFromUrl('https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf'),

with placeholder until pdfFile download and errorWidget if there are problem
      PDF().cachedFromUrl(
             'https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf',
             placeholder: (progress) => Center(child: Text('$progress %')),
             errorWidget: (error) => Center(child: Text(error.toString())),
           )

For production usage

If you use proguard, you should include this line [ready-made in the Example].

-keep class com.shockwave.**

Dependencies

Flutter

flutter_pdfview

flutter_cache_manager

Android (only support >= api 20)

AndroidPdfViewer

iOS (only support> 11.0)

PDFKit

Video

IOS

WEB

Developer
Abdelrahman Saed GitHub avatar
GitHub 作者

Abdelrahman Saed ↗

Software engineer with professional experience focused in Flutter, previous experience with Android native(java), and familiar with backend using NodeJS, AWS

@iStoriaEEgypt
语言DartRubyShellSwiftKotlinObjective-C

分类

此仓库发布的插件

使用的依赖

依赖清单 6 项

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗