flutter_pdfview 2.0.0-beta.2
flutter_pdfview: ^2.0.0-beta.2 copied to clipboard
A Flutter plugin that provides a PDFView widget on Android and iOS.
2.0.0-beta.2 #
No API or native changes since 2.0.0-beta.1; this release refreshes what pub.dev shows.
- The example app is now a feature showcase: a complete reader (page slider, go to page, zoom,
page colors, fit modes, find in document, password prompt, error screen), every
PdfSourcewith copyable code, and a playground with every option, a log of every callback and the generatedPDFView(...)code - README: iOS and Android screenshots, and a guide to the example app
- CI now builds the plugin for the iOS simulator and runs the integration tests against PDFKit, alongside the Android emulator runs for both engines
2.0.0-beta.1 #
First 2.0.0 pre-release. It ships the whole 1.5.0-beta.1 → 1.5.0-beta.12 line, plus the new
text layer, under a new major version, because a few defaults and behaviours change for apps
upgrading from 1.4.5.
Pre-releases are not picked up by a ^ constraint; pin flutter_pdfview: 2.0.0-beta.1 to try it.
Breaking changes #
- BREAKING:
PDFView.colorModedefaults toPdfColorMode.system, so pages follow the app's theme. An app with a dark theme now shows inverted (dark) pages where1.4.5always rendered them light. PasscolorMode: PdfColorMode.lightto keep the old look.nightModestill works but is deprecated in favour ofcolorMode(#215, #138) - BREAKING (iOS): settings changed when
PDFViewis rebuilt (enableSwipe,colorMode,backgroundColor,password,minZoom/maxZoom,pageAlignment,preventLinkNavigation) are now applied on iOS.1.4.5silently ignored them there; Android already applied them - BREAKING (Android): the default Android engine is now Android's own PDF renderer through
Jetpack
androidx.pdf, replacing AndroidPdfViewer/PDFium. Apps no longer bundle PDFium and gain the text layer on Android, but the app must setminSdkVersion 28(Android 9) andcompileSdkExtension 19, pages scroll vertically only (swipeHorizontal,pageFling,pageSnapare ignored), and the PDFium-specificenableAntialiasing,useBestQuality,enableRenderDuringScale,thumbnailRatioandsetPage(withAnimation:)have no effect. Apps that need horizontal paging, Android 5.0–8.1, or password-protected PDFs on Android 9–10 (the default engine opens those from Android 15, or 11+ with the PDF system update, and otherwise reports an explanatoryonError) add the new opt-influtter_pdfview_android_pdfiumpackage, which keeps the 1.x engine unchanged - BREAKING (build): the Android plugin is written in Kotlin (Kotlin Gradle plugin 2.0.0, JVM 17) and the iOS plugin in Swift 5.9. Public Dart API, import path and the registered native class names are unchanged
Document sources #
- New
PDFView.sourcetakes aPdfSource, so the common cases need no copying:PdfSource.asset('assets/manual.pdf')opens a Flutter asset natively, from the app bundle on iOS (no copy) and the APK on Android, without its bytes passing through DartPdfSource.network(url, headers: ...)downloads to a temporary file first, shows the newPDFView.placeholdermeanwhile, reports failures (including non-2xx statuses) throughonError, and deletes the file when the view goes awayPdfSource.uri(uri)opensfile:URIs everywhere andcontent:URIs on Android (the system file picker, other apps' providers)PdfSource.file(path)andPdfSource.bytes(data)match the existingfilePath/pdfData
filePathandpdfDatakeep working unchanged. Sources compare by value: rebuilding with an equal source keeps the document open; a different one loads the new document- A missing asset reports
onErrorwith "Asset not found: …" on every engine - Adds
example/integration_test/sources_test.dartand a "Document sources" example screen
Text layer #
- Add the text layer: find-in-document (#137), text selection (#285) and the ability to stop text being copied out (#108)
- New on
PDFViewController:searchText,nextMatch,previousMatch,setCurrentMatch,clearSearch,getSelectedText,clearSelection, andisTextLayerSupported - New on
PDFView:enableTextSelectionandenableCopy(both defaulttrue, both update at runtime without remounting), plus theonTextSelectionChangedandonSearchResultChangedcallbacks - iOS: implemented on PDFKit —
findStringwith every match highlighted, the active one scrolled into view, wrapping navigation, and an edit menu that drops copy / share / look-up whenenableCopyisfalse - Android: implemented on
androidx.pdffor Android 15+, and Android 11+ with the PDF system update (SDK extension 13);isTextLayerSupported()isfalseon Android 9–10, where the renderer cannot search —searchDocumentwith every match highlighted and the active one scrolled into view, wrapping navigation,PdfViewselection reported throughonTextSelectionChanged, andenableCopy: falseremoving Copy, Copy link and smart actions from the selection menu. The renderer searches case-insensitively;caseSensitive: truefilters hits against the page text flutter_pdfview_android_pdfiumhas no text layer (AndroidPdfViewer'sPdfiumCorebinds none of Pdfium'sFPDFText_*API). There the query methods throwUnsupportedErrorrather than returning an empty list, which would read as "no matches". CheckisTextLayerSupported()before offering search or selection UI- Adds
example/integration_test/text_layer_test.dart, which drives the real native viewer, and a deterministic text fixture (scripts/make_text_pdf.py) - Example app: Search Text in PDF home action +
TextSearchScreen(gate onisTextLayerSupported, search/next/prev, selection and copy chips) - Docs: package README text-layer section and controller table, platform-interface README
contract,
Claude.mdfeatures/testing notes,example/README.mddemo map - Depends on
flutter_pdfview_platform_interface^1.1.0
Fixes since 1.5.0-beta.12 #
-
Android: apps on Flutter 3.50's default template (AGP 9 with
android.builtInKotlin=false) failed to build with "Could not find method kotlin()": the plugin skipped the Kotlin Gradle plugin on AGP 9, and Flutter, matching the plugin'sapply plugin: 'kotlin-android'text, skipped it too. The plugin now applies it whenever built-in Kotlin is off -
Settings changed while the native view was still being created are no longer dropped: they are sent once the view exists
-
Android: a
setPagecall still queued when the view is disposed now completes withfalseinstead of never completing -
Android: a runtime
minZoomabovemaxZoomis clamped the same way as at creation -
iOS:
reload()can no longer leave the document hidden when the fit scale is not ready yet. As in1.4.5, it fires no render callbacks -
iOS:
onTapno longer fires for the tap that stops a scroll, nor twice for a double-tap zoom -
iOS: the
getScreenshotfallback respects zoom, scroll offset and page rotation -
iOS:
PDFView.passwordcleared back tonullat runtime keeps the document open (Android reopens it); documented onPDFView.password -
Equal
pdfDatapassed as a newUint8Listis compared byte for byte instead of hashed twice per rebuild
Everything in 1.5.0-beta.1 → 1.5.0-beta.12 below is included. Feedback is welcome in
#351.
1.5.0-beta.12 #
- Add optional
withAnimationtoPDFViewController.setPage(#251): Android animates viajumpTo(page, withAnimation); iOS ignores the flag (PDFKit has no equivalent). Defaults tofalse, so existing callers keep the previous instant jump - Add optional
PDFView.spacing(#335): gap between pages whenautoSpacingis true (dp on Android, points on iOS).nullpreserves historical platform defaults and top-alignment gaps from beta.8 - Depends on
flutter_pdfview_platform_interface^1.0.1 - Includes everything in
1.5.0-beta.11
1.5.0-beta.11 #
- Split the plugin into a federated structure. The shared value types, the settings/creation-param
wire format and the method-channel plumbing now live in the new
flutter_pdfview_platform_interfacepackage, andPDFViewreaches the native views throughFlutterPdfViewPlatform.instance - No public API changes and no changes to the native code.
PDFView,PDFViewController, every callback,FitPolicy,PageAlignment,PdfColorModeandPDFPasswordFailurekeep the same names, semantics and import path — the value types are re-exported frompackage:flutter_pdfview/flutter_pdfview.dart, so app code needs no changes. The platform-view type and the per-view method channel are unchanged, so existing native implementations keep working. The full 1.5.0-beta.10 Dart test suite passes unmodified - Adding a platform (web, macOS, Windows) no longer requires touching this package: an
implementation extends
FlutterPdfViewPlatformand registers itself - The repository is now a Melos + Dart pub workspaces monorepo; the published package moved to
packages/flutter_pdfview/ - iOS: declare the
FlutterFrameworkdependency inPackage.swift, which Flutter 3.44+ requires plugins to do explicitly instead of inheriting it from the generated Runner package. This clears the "missing a dependency on FlutterFramework" warning printed on everyflutter pub getand Swift Package Manager build - Android: prepare for Built-in Kotlin.
AGP 9 compiles Kotlin itself and Flutter fails the build of any app whose plugins also apply the
Kotlin Gradle Plugin, so
kotlin-androidis now applied only on AGP 8, andkotlinOptionsis replaced by thekotlin { compilerOptions { jvmTarget } }form that both toolchains understand. Apps on AGP 8 are unaffected; apps on AGP 9 no longer fail because of this plugin. The KGP warning itself only disappears once your app is on AGP 9 withandroid.builtInKotlin=true - Includes everything in
1.5.0-beta.10
1.5.0-beta.10 #
- Fix #274: password-protected documents can
now be unlocked from the app instead of leaving a blank view. New
onPasswordRequiredcallback reports whether the document needs a password or was given the wrong one, and the newPDFViewController.unlock(password)— or simply rebuildingPDFViewwith a newpassword— reopens the document in place, so a wrong password can be retried without recreating the view - iOS: an encrypted document no longer skips the scroll-view/page setup it needs, so a document
unlocked after the prompt renders and navigates like any other;
getPageCount()no longer returns null between the render callback and the first layout pass - Add end-to-end tests (
example/integration_test/) that drive the real native viewers against an encrypted document, plus Dart and Android unit coverage for the new API - Includes everything in
1.5.0-beta.9
1.5.0-beta.9 #
- Fix #215: night mode used a naive channel invert that turned photos into negatives. Dark mode now uses a luminance-preserving inversion on both platforms so white↔black while hue is kept (#348, #349, #350)
- Fix #138: iOS dark mode via
FPVThemedPage - Android:
colorModevia hardware-layerColorMatrixColorFilter(replacingsetNightMode); gutters use matrix-compensated background; screenshots usesaveLayerfor theme-correct captures - Dart: add
PdfColorMode(light/dark/system) andPDFView.colorMode(defaultsystem); deprecatenightMode(still honored whencolorModeis left atsystem) - Runtime updates include
colorModeandbackgroundColorwithout remounting; iOSonUpdateSettingsis now live for color, background, swipe, zoom limits, and link navigation - Includes everything in
1.5.0-beta.8
1.5.0-beta.8 #
- Add
PageAlignment(centerdefault,top) so short / single-page documents can pin to the top of the viewport instead of being vertically centered (#250, #272, #358); iOS page-break margins put free space below the page when top-aligned - Fix Android
setPage/jumpToleaving pages left-aligned on the secondary axis — re-center horizontally after page changes (#197) - Includes everything in
1.5.0-beta.7
1.5.0-beta.7 #
- Improve Android/iOS render quality defaults for #158
(#357):
density-aware page-part cache, apply Dart’s
thumbnailRatio0.8 when the param is omitted (AndroidPdfViewer’s static default is 0.3), keepuseBestQuality/enableAntialiasing/enableRenderDuringScaletrue when params are missing, pin iOScontentScaleFactorto the screen scale, and document quality knobs + hard Pdfium limits in the README - Includes everything in
1.5.0-beta.6
1.5.0-beta.6 #
- Fix #175:
getScreenshotno longer returns a white image under hybrid composition. Android captures viaPixelCopy(with a software-layerView.drawfallback); iOS rasterizes the PDFKit layer and falls back to drawing the currentPDFPage(drawing-cache / hierarchy snapshots are avoided on both platforms) (#356) - Includes everything in
1.5.0-beta.5
1.5.0-beta.5 #
- Fix load flash / first-layout size / iOS blank open (#355):
- #40: keep the native view hidden until the first successful render/fit so transitions do not flash an empty or mid-load surface
- #127: harden first layout fit — defer document open until a non-zero size, re-fit when the platform view settles after the first paint
- #190: iOS defers
PDFDocumentopen until usable bounds, reports missing/unreadable/corrupt/empty documents viaonError, and forces a layout pass after attach so the PDF is not stuck blank until background/foreground
- Includes everything in
1.5.0-beta.4
1.5.0-beta.4 #
1.5.0-beta.3 #
1.5.0-beta.2 #
1.5.0-beta.1 #
Native language migration on both platforms. Includes everything in 1.4.5.
- Android: migrate the plugin implementation from Java to Kotlin (KGP 2.0.0, JVM target 17). Behavior verified by the existing 64-test native suite running against the Kotlin sources unchanged
- iOS: migrate the plugin implementation from Objective-C to Swift 5.9. The registered
FLTPDFViewFlutterPluginclass name is preserved,NSExceptionguards around PDFKit are kept via a small Objective-C shim target, and scroll observation moved to block-based KVO. Verified on both Swift Package Manager and CocoaPods (pod lib lint, dynamic + static) - Fix a platform-view remount race: late creation callbacks from a disposed or remounted view can no longer complete the new controller with a stale instance
- Harden iOS
setZoomLimitsand align the podspecswift_version - No public Dart API changes
1.4.5 #
Stable release of the 1.4.5-beta.1 → 1.4.5-beta.5 line; no code changes since 1.4.5-beta.5.
Highlights since 1.4.4 (see the beta sections below for the full list):
- BREAKING: minimum Flutter 3.32.0 / Dart 3.8.0
- BREAKING: Android platform views now use true hybrid composition (
initExpensiveAndroidView) — fixes surface lock #263,EGL_NO_DISPLAYcrash #280, blanking on rotation #9 / dialogs #182 / load #298, and GPU glitches #306 - BREAKING: Android external PDF links only auto-launch
http/https; other schemes are reported throughonLinkHandlerinstead - iOS:
fitPolicy(WIDTH / HEIGHT / BOTH) implemented for Android parity, page fit decoupled fromautoSpacing#150,onErroron bad passwords/documents #211, white background and continuous scrolling #204, Privacy Manifest #271 - Android: Java 17 toolchain #334, dispose/memory-leak fixes #261, absolute-path loading #266,
libc++_shared.sopackaging #287 - New API:
minZoom/maxZoom#296,showScrollIndicators#337,onLoadComplete/onDraw,getCurrentPageSize(),getScreenshot(),getPosition()/setPosition(),getScale()/setScale(),reload(),setZoomLimits()#333 - Document remount when
filePath/pdfDatachanges #181
Migration from 1.4.4 #
- Raise your app to Flutter ≥ 3.32 and Dart ≥ 3.8.
- Android PDF views now use expensive hybrid composition (true platform views); re-check layout and gesture behavior if you embed
PDFViewin complex widget trees. - Non-
http(s)PDF links no longer auto-open — handle them yourself inonLinkHandler.
1.4.5-beta.5 #
- Fix #150: iOS initial page fit no longer depends on
autoSpacing(spacing vs zoom decoupled); re-fit after placeholder→real bounds and on rotation while preserving user zoom - Implement
fitPolicy(WIDTH / HEIGHT / BOTH) on iOS for parity with Android (iOS previously ignored the flag and always auto-fit the full page; defaultFitPolicy.WIDTHnow matches Android) - Add regression tests for #150 creation-param independence (Dart iOS/Android + Android Robolectric) and iOS fit-scale formula oracle
- Make standalone Android unit tests runnable:
compileOnlyFlutter embedding jar, fixandroid/settings.gradle, addscripts/run_android_unit_tests.sh
1.4.5-beta.4 #
- BREAKING: Raise minimum Flutter version to 3.32.0 and Dart SDK to 3.8.0 (aligns with
flutter_lints6 andformatter.page_width) - Android: switch platform views from texture hybrid composition (
initSurfaceAndroidView) to true hybrid composition (initExpensiveAndroidView) — fixesSurface was already locked!#263,EGL_NO_DISPLAYquick-open crash #280, blank on rotation #9, blank after dialogs #182, blank on load #298, and GPU glitches #306 - Fix Android layout direction to follow ambient
Directionality(was hardcoded RTL) - Fix #181: remount platform view when
filePath/pdfDatachanges so a new PDF can load - Fix #261: release Pdfium/PDFKit resources on dispose (Android recycle race + iOS observers/document/channel)
- Restrict Android external PDF link auto-launch to
http/https(avoidsfile://crashes and unsafe schemes); still reports all schemes viaonLinkHandler - Serialize concurrent
setPosition/setScalethrough a queue for any number of overlapping callers; null platform replies returnfalse - Compare
pdfDatavia cached digests instead of a full per-byte scan on every rebuild - Fix #268: avoid NaN CoreGraphics errors by initializing iOS
PDFViewwith a non-zero frame - Fix #204: iOS white background (not grey) and continuous vertical page scroll parity with Android
- Fix #266: load absolute filesystem paths via
fromFileon Android (No content provider) - Fix #287:
pickFirstpackaging forlibc++_shared.sonative merge conflicts - Defer Android PDF load until the view has non-zero size; safer dispose before surface draw races
- Propagate
nightModesetting updates to native Android view - Document
EagerGestureRecognizerfor PDFView inside scrollables #265 - Fix Android external PDF links silently failing on API 30+ package visibility (
resolveActivitypre-check) - Fix controller deadlock: a failed
setPosition/setScalecall permanently hung all later position/scale calls - Fix iOS silently showing a blank view for wrong/missing passwords — now fires
onError(parity with Android) - Fix iOS
getCurrentPage/onPageChangedreporting a garbage index (NSNotFound) before a page is loaded - Validate
thumbnailRatioto (0, 1] (Dart assert + Android clamp) — out-of-range values crashed rendering - Restructure Dart library into
lib/src/part files; public API unchanged - Adopt
flutter_lints6.0 with zero analyzer issues; dartdoc for the entire public API - Expand unit tests: controller method channel, native→Dart callbacks, document remount, creation settings
- Add 64 Android native unit tests (Robolectric/JUnit): URI handling, param parsing, link handler, thumbnail clamp
- Replace broken example widget test with home-screen / PDFScreen chrome coverage
- Fix Android
setPageresolving before the jump executes; reload pages whennightModechanges; handle unescapedfile:URIs on iOS
1.4.5-beta.3 #
- Fixed issue #337: Added showScrollIndicators option to control native scroll indicator visibility.
1.4.5-beta.2 #
- Fix iOS PDF view reporting not ready when it is on initial load
- Add
minZoomandmaxZoomto the README.md - Fix Android memory leak by recycling
PDFViewon dispose
1.4.5-beta.1 #
- Upgrade Java source/target compatibility from 1.8 to 17 #334
- Add iOS Privacy Manifest (PrivacyInfo.xcprivacy) #271
- Fix iOS
onErrorcallback not firing for invalid documents #211 - Fix iOS
onPageChangednot triggered on first load #66 - Fix iOS landscape PDF wrong initial zoom by preserving user-configured max scale factor #247
- Add configurable
maxZoomandminZoomparameters #296 - BREAKING: Raise minimum Flutter version to 3.27.0 and Dart SDK to 3.6.0
- Migrate
backgroundColorserialization from deprecatedColor.valuetoColor.toARGB32() - Update iOS deployment target to 13.0 in podspec and Package.swift (aligns with Flutter's own iOS 13.0+ requirement)
- Fix example app build error with undefined
nightModeBackgroundColorparameter - Add
onLoadCompletecallback triggered when the PDFView has loaded its document #333 @JaseElder - Add
onDrawcallback triggered on each draw within the PDFView #333 @JaseElder - Add
getCurrentPageSize()controller method returning width and height of the loaded page #333 @JaseElder - Add
getScreenshot(String fileName)controller method to save a PNG of the PDFView contents #333 @JaseElder - Add
getPosition()andsetPosition(Offset position)controller methods for the PDF top-left offset #333 @JaseElder - Add
getScale()andsetScale(double scale)controller methods for PDF zoom #333 @JaseElder - Add
reload()controller method to reload the PDF document #333 @JaseElder - Add
setZoomLimits(double minZoom, double midZoom, double maxZoom)controller method #333 @JaseElder - Add safe unboxing and completers for get/set viewport position to avoid contention and race conditions #333 @JaseElder
- Upgrade AndroidPdfViewer to 3.2.8 #333 @JaseElder
- Fix deprecated color
.valueusage #333 @JaseElder
1.4.3 #
- Stable Android 16KB page size support
- Fix iPad scroll direction crash issue #325
- Add defensive scroll view configuration for iPad devices
- Implement gesture conflict resolution to prevent "Failed to determine navigation direction for scroll" errors
- Add safe layout updates during scrolling animations
- Use more conservative scroll settings on iPad to improve compatibility
- Add iPad Safe Mode example in demo app for recommended PDF configurations on iPad
1.4.2-beta.1 #
- Add Android 16KB page size support #321 @opsenes
- Update Android PDF viewer library to
io.github.oothp:android-pdf-viewer:3.2.0-beta05 - Upgrade Android Gradle Plugin to 8.11.1
- Upgrade Gradle wrapper to 8.14.3
- Enable AndroidX support
1.4.1+1 #
- Revert
.toARGB32()to depricated.value
1.4.0+1 #
- Add error handling on background color in iOS
1.4.0 #
- Add support for Swift Package Manager
1.3.3 #
- hotfix: Crash on iOS 18
1.3.1 #
- Upgrade compileSdkVersion to 33
- Upgrade sdk
1.3.0 #
- Upgrade android-pdf-viewer to beta.3
1.2.9 #
- Deprecate
fitEachPage
1.2.8 #
- Add documentation on properties
1.2.7 #
- Downgrade android-pdf-viewer from beta.3 to beta.2
- Upgrade Gradle to 7.3.0
1.2.1 #
- Updated dependencies to be newest with latest flutter version.
- Update minimal version of flutter to 2.2.0
- Updated compileSdkVersion in Android gradle to 30 because in future new apps on Google Play will have to set at least compile version to 30
- Updated README #148 @PcolBP
1.0.3+1 #
- Format lib/flutter_pdfview.dart
1.0.2 #
- pod_target_xcconfig suggested by @zhenpeng0hou
1.0.1 #
- Add support on FitPolicy on android
1.0.0+12 #
- FIX: plugin class name
1.0.0+11 #
- add defaultPage option
1.0.0+9 #
- Avoid Android Native crash when file is not valid
1.0.0+7 #
- upgrade path_provider version
1.0.0+6 #
- FIX: onRender not works in iOS
1.0.0+5 #
- onRender handlers added
- onError, onPageError handlers added (Android only)
- Add example snippet in readme
1.0.0+4 #
- Add controller functions description in document
1.0.0+3 #
- Support
enableSwipein iOS
1.0.0+2 #
- Set correct scale in iOS
1.0.0+1 #
- Update pub description
1.0.0 #
- Initial Release
- Works better