flutter_pdfview
Native PDF viewer for Flutter on iOS and Android. It shows documents with the
platform's own renderer: PDFKit on iOS, and Android's PDF renderer (Jetpack
androidx.pdf) on Android, so there is no PDF engine to bundle.
- Open from anywhere: assets, files,
content://URIs, bytes and URLs (Loading documents) - Text layer: search with highlights, text selection, and control over copying (Text layer)
- Password-protected PDFs, with a callback to prompt the user and retry (Passwords)
- Dark mode that follows your app's theme, without turning photos into negatives
- Paging, zoom, fit and alignment controls, driven from Dart through
PDFViewController
Screenshots
iOS (PDFKit)
![]() | ![]() | ![]() | ![]() |
| Showcase | Reader | Find in document | Dark pages |
Android (androidx.pdf)
![]() | ![]() | ![]() | ![]() |
| Showcase | Reader | Find in document | Dark pages |
From the example app. Run it with flutter run in example/ to try every
feature; its Playground screen shows the PDFView(...) code for whatever options you set.
Contents
- Screenshots
- Installation
- Quick start
- Loading documents
- Navigating and zooming
- Android engines
- All options · Controller methods
- Password-protected documents · Text layer
- Migrating from 1.x
- Troubleshooting
- Limitations
Installation
dependencies:
flutter_pdfview: 2.0.0-beta.2
2.0.0-beta.2 is a pre-release, so pin it exactly: a ^ constraint does not pick
up pre-releases. The current stable release is 1.4.5; see
Migrating from 1.x for what changes. Feedback on the beta is
welcome in #351.
Platform setup
Android. The default engine needs Android 9 (API 28) and an app that compiles
against SDK extension 19. Set both in android/app/build.gradle:
android {
compileSdk 36
compileSdkExtension 19 // required by androidx.pdf
defaultConfig {
minSdkVersion 28
}
}
Need Android 5.0–8.1 or horizontal paging? Add the PDFium engine instead of raising the minimum: see Android engines.
iOS. iOS 13 or later. With CocoaPods, make sure ios/Podfile has
platform :ios, '13.0' (or higher). Swift Package Manager is supported too.
No permissions are needed to open files your app owns, its assets, or documents the user picks with the system file picker.
Quick start
import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
class ManualScreen extends StatelessWidget {
const ManualScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Manual')),
body: PDFView(
source: const PdfSource.asset('assets/manual.pdf'),
onError: (error) => debugPrint('PDF error: $error'),
),
);
}
}
List the file under flutter: assets: in your app's pubspec.yaml, as with any
asset.
Loading documents
Pass a PdfSource as source:
| Source | Use it for | How it loads |
|---|---|---|
PdfSource.asset('assets/a.pdf') |
PDFs shipped with the app | Natively from the app bundle; the bytes never pass through Dart |
PdfSource.file(path) |
Files your app downloaded or saved | Natively from disk |
PdfSource.uri(uri) |
file: URIs, and content: URIs on Android (file pickers, other apps) |
Natively |
PdfSource.network(url, headers: ...) |
Documents on a server | Downloaded to a temporary file, then opened |
PdfSource.bytes(data) |
Documents you already hold in memory | Copied across the platform channel |
// A URL, with an auth header and a spinner while it downloads.
PDFView(
source: PdfSource.network(
Uri.parse('https://example.com/statement.pdf'),
headers: {'Authorization': 'Bearer $token'},
),
placeholder: const Center(child: CircularProgressIndicator()),
onError: (error) => showError(error), // network errors and non-2xx statuses too
)
// A document the user picked (a content:// URI on Android).
PDFView(source: PdfSource.uri(pickedUri))
Tips:
- Prefer asset, file and URI sources over bytes.
PdfSource.bytescopies the whole document across the platform channel, and Android then writes it to a file anyway, because the renderer needs one. - Changing
sourceloads the new document in the samePDFView. Sources compare by value, so rebuilding with an equal source keeps the document open. - Network downloads are not cached. For offline use or a progress bar,
download the file yourself (for example with
package:httpandpath_provider) and passPdfSource.file. - Plain
http://URLs are blocked by default on Android 9+ and iOS. Usehttps://. filePathandpdfDatastill work: they are the same asPdfSource.fileandPdfSource.bytes.- PDF is the only document format: both native renderers are PDF viewers.
Navigating and zooming
onViewCreated hands you a PDFViewController. It, together with
onPageChanged, is all you need for your own page slider, "go to page" field or
zoom buttons:
PDFViewController? _controller;
int _page = 0, _pages = 0;
PDFView(
source: source,
onViewCreated: (controller) => _controller = controller,
onRender: (pages) => setState(() => _pages = pages ?? 0),
onPageChanged: (page, total) => setState(() => _page = page ?? 0),
)
// A page slider:
Slider(
value: _page.toDouble(),
max: _pages > 1 ? (_pages - 1).toDouble() : 1,
onChanged: (value) => _controller?.setPage(value.round()),
)
// Zoom in by 50%:
final scale = await _controller!.getScale();
await _controller!.setScale(scale * 1.5);
Scale is relative to the fitted page (1.0 = fitted per fitPolicy) on every
platform and engine, and stays between minZoom and maxZoom.
Android engines
Since 2.0, Android renders PDFs with Android's own PDF engine through
Jetpack androidx.pdf,
so your app no longer ships PDFium. It also brings the
text layer — search, selection and copy control — to Android.
It needs Android 9 (API 28) and compileSdkExtension 19; see
Platform setup.
If your app needs horizontal paging (swipeHorizontal, pageFling,
pageSnap) or must run on Android 5.0–8.1, add the opt-in PDFium engine,
which is the engine flutter_pdfview 1.x used, next to flutter_pdfview:
dependencies:
flutter_pdfview: 2.0.0-beta.2
flutter_pdfview_android_pdfium: 1.0.0-beta.1
Nothing else changes in your code; iOS is unaffected.
Default (androidx.pdf) |
flutter_pdfview_android_pdfium |
|
|---|---|---|
| Minimum Android | 9 (API 28) | 5.0 (API 21) |
| Bundled native PDF libraries | None | PDFium, several MB per CPU architecture |
| Text layer (search, selection, copy control) | ✅ on Android 15+, or Android 11+ with the PDF system update; ❌ on Android 9–10 | ❌ (UnsupportedError) |
| Password-protected PDFs | ✅ on Android 15+, or Android 11+ with the PDF system update; on Android 9–10 onError explains why it cannot open them |
✅ |
Horizontal paging (swipeHorizontal, pageFling, pageSnap) |
❌ vertical only | ✅ |
thumbnailRatio, useBestQuality, enableAntialiasing, enableRenderDuringScale |
Ignored (managed by Android) | ✅ |
setPage(withAnimation:) |
Ignored | ✅ |
All options
| Name | Android (default) | Android (PDFium) | iOS | Default |
|---|---|---|---|---|
| defaultPage | ✅ | ✅ | ✅ | 0 |
| onViewCreated | ✅ | ✅ | ✅ | null |
| onRender | ✅ | ✅ | ✅ | null |
| onPageChanged | ✅ | ✅ | ✅ | null |
| onLoadComplete | ✅ | ✅ | ✅ | null |
| onDraw | ✅ | ✅ | ✅ | null |
| onTap | ✅ | ✅ | ✅ | null |
| onTextSelectionChanged | ✅¹ | ❌ | ✅ | null |
| onSearchResultChanged | ✅¹ | ❌ | ✅ | null |
| enableTextSelection | ✅¹ | ❌ | ✅ | true |
| enableCopy | ✅¹ | ❌ | ✅ | true |
| onError | ✅ | ✅ | ✅ | null |
| onPageError | ❌ | ✅ | ❌ | null |
| onPasswordRequired | ✅¹ | ✅ | ✅ | null |
| onLinkHandle | ✅ | ✅ | ✅ | null |
| gestureRecognizers | ✅ | ✅ | ✅ | null |
| source | ✅ | ✅ | ✅ | |
| filePath / pdfData | ✅ | ✅ | ✅ | |
| placeholder | ✅ | ✅ | ✅ | empty box |
| fitPolicy | ✅ | ✅ | ✅ | FitPolicy.WIDTH |
| pageAlignment* | ✅ | ✅ | ✅ | PageAlignment.center |
| enableSwipe | ✅ | ✅ | ✅ | true |
| swipeHorizontal | ❌ | ✅ | ✅ | false |
| password | ✅¹ | ✅ | ✅ | null |
| colorMode | ✅ | ✅ | ✅ | PdfColorMode.system |
| nightMode* | ✅ | ✅ | ✅ | false |
| autoSpacing* | ✅ | ✅ | ✅ | true |
| spacing* | ✅ | ✅ | ✅ | null |
| pageFling | ❌ | ✅ | ✅ | true |
| pageSnap | ❌ | ✅ | ❌ | true |
| preventLinkNavigation | ✅ | ✅ | ✅ | false |
| backgroundColor | ✅ | ✅ | ✅ | null |
| minZoom | ✅ | ✅ | ✅ | 1.0 |
| maxZoom | ✅ | ✅ | ✅ | 4.0 |
| showScrollIndicators* | ✅ | ✅ | ✅ | false |
| enableAntialiasing | ❌ | ✅ | ❌ | true |
| useBestQuality | ❌ | ✅ | ❌ | true |
| enableRenderDuringScale | ❌ | ✅ | ❌ | true |
| thumbnailRatio* | ❌ | ✅ | ❌ | 0.8 |
¹ Needs Android 15, or Android 11+ with the PDF system update (S extension 13). On older devices text queries throw UnsupportedError and a password-protected file reports onError instead; check isTextLayerSupported().
Notes:
- Give exactly one of
source,filePathandpdfData— see Loading documents.placeholdershows while aPdfSource.networkdocument downloads. enableTextSelectionandenableCopywork on iOS and on Android's default engine. Withflutter_pdfview_android_pdfiumthere is no text layer, so they have no effect — see Text layer, and always checkisTextLayerSupported()before offering that UI.swipeHorizontal,pageFlingandpageSnapneedflutter_pdfview_android_pdfiumon Android: the default engine scrolls vertically only.enableAntialiasing,useBestQuality,enableRenderDuringScaleandthumbnailRatioare PDFium-engine settings and are ignored by the default engine. See Android engines.colorModethemes page content and the gutter on both platforms. Values:PdfColorMode.light,PdfColorMode.dark,PdfColorMode.system(default).systemfollows the appThemebrightness (or platform brightness when noThemeis present) and is resolved in Dart before being sent to the native view. Dark mode uses a luminance-preserving inversion (hue kept; photos do not become pure negatives). Live updates apply without remounting the platform view.nightModeis deprecated. PrefercolorMode. WhencolorModeis left atsystemandnightMode: true, the resolved mode isdark. An explicitcolorModealways wins.backgroundColorcan be updated at runtime together withcolorMode. Setting it back tonullafter a non-null value leaves the previous color on screen.passwordcan be changed after the first build: the document is reopened in place, so the platform view is not recreated. See Password-protected documents.spacingsets the gap between pages whenautoSpacingis true (dp on Android, points on iOS).nullkeeps each platform's default (Android: the default engine's own gap, or 0 / 8 with top alignment on the PDFium engine; iOS 4 top+bottom / 8 bottom-only with top alignment). Creation-time only — remount the view to change it (#335).showScrollIndicatorsis ignored on iOS while horizontal page-flipping is active (pageFling: truetogether withswipeHorizontal: true).autoSpacingonly adds gaps between pages. It does not change initial zoom orfitPolicy(fixed in #150).thumbnailRatiomust be in(0, 1]. Higher values look sharper while tiles load but use more memory.pageAlignmentcontrols where a document that is shorter than the viewport sits. The defaultPageAlignment.centermatches historical AndroidPdfViewer / PDFKit behavior. UsePageAlignment.topso free space is below the page (typical for single-page PDFs — #250, #272):
PDFView(
source: source,
pageAlignment: PageAlignment.top,
backgroundColor: Colors.grey.shade200,
)
Controller methods
| Name | Description | Parameters | Return |
|---|---|---|---|
| getPageCount | Get total page count | - | Future<int> |
| getCurrentPage | Get current page | - | Future<int> |
| setPage | Go to/Set page | int page, withAnimation (optional; animates only on the PDFium engine) |
Future<bool> |
| getCurrentPageSize | Return the width and height of the loaded page | - | Future<Size> |
| getScreenshot | Create a PNG of the contents of the PDFView and save to fileName | String fileName |
Future<String> |
| getPosition | Get the position of the top left of the PDF with respect to the origin (top left of PDFView) | - | Future<Offset> |
| getScale | Get the PDF zoom value, for zooming | - | Future<double> |
| setPosition | Set the position of the top left of the PDF with respect to the origin (top left of PDFView) | Offset position |
Future<bool> |
| setScale | Set the PDF zoom value, for zooming | double scale |
Future<bool> |
| setZoomLimits | Set the minimum, maximum and mid bounds of the zoom limits | double minZoom, double midZoom, double maxZoom |
- |
| unlock | Reopen the document with a password, for encrypted PDFs (#274) | String password |
Future<bool> |
| reload | Reload the PDF document in the PDFView | - | Future<bool> |
| isTextLayerSupported | Whether this platform can search/select text — see Text layer | - | Future<bool> |
| searchText | Find every occurrence of a string; activates the first match | String query, {bool caseSensitive} |
Future<List<PdfTextMatch>> |
| nextMatch | Activate the next match, wrapping at the end | - | Future<PdfTextMatch?> |
| previousMatch | Activate the previous match, wrapping at the start | - | Future<PdfTextMatch?> |
| setCurrentMatch | Activate a match by index | int index |
Future<PdfTextMatch?> |
| clearSearch | Clear highlights and forget the last search | - | Future<void> |
| getSelectedText | The currently selected text, or null | - | Future<String?> |
| clearSelection | Clear the current text selection | - | Future<void> |
Password-protected documents
Pass the password up front with password when you already know it. When you do
not, onPasswordRequired tells you that the document is encrypted — either
because no password was supplied (PDFPasswordFailure.missing) or because the
one you supplied did not open it (PDFPasswordFailure.incorrect) — so you can
prompt the user and try again (#274):
PDFView(
filePath: path,
password: _password,
onPasswordRequired: (PDFPasswordFailure failure) async {
final String? entered = await showPasswordDialog(
context,
retry: failure == PDFPasswordFailure.incorrect,
);
if (entered != null) {
// Either rebuild with the new password ...
setState(() => _password = entered);
// ... or hand it straight to the controller:
// await controller.unlock(entered);
}
},
)
Both routes reopen the document inside the existing platform view, so a wrong
password can be retried as often as needed without rebuilding the viewer.
onError still fires alongside onPasswordRequired, so viewers written before
this callback existed keep working.
Text layer
Text selection (#285), find-in-document (#137) and blocking copy (#108) all need the document's text layer.
Supported on iOS (PDFKit) and on Android's default engine (androidx.pdf) on
Android 15+, or Android 11+ devices that have the PDF system update (SDK
extension 13). On Android 9–10 the default engine renders documents but has no
text layer, so isTextLayerSupported() reports it per device.
The opt-in flutter_pdfview_android_pdfium engine has no text layer:
AndroidPdfViewer's PdfiumCore binds none of Pdfium's FPDFText_* API in Java.
On Android, a search is case-insensitive in the renderer; caseSensitive: true
filters those hits against the page text.
Always branch on isTextLayerSupported(). The query methods throw
UnsupportedError where there is no text layer, deliberately: returning an empty
list would be indistinguishable from "this document contains no matches", and
apps would ship broken search without noticing. clearSearch and
clearSelection stay no-ops everywhere, because clearing nothing is truthful.
late PDFViewController controller;
if (await controller.isTextLayerSupported()) {
final List<PdfTextMatch> matches = await controller.searchText('invoice');
// The first match is already highlighted and scrolled into view.
for (final PdfTextMatch match in matches) {
debugPrint('match ${match.matchIndex} on page ${match.pageIndex}: ${match.text}');
}
await controller.nextMatch(); // wraps at the end
await controller.clearSearch();
} else {
// Hide the search UI rather than calling and catching.
}
Track the active match with onSearchResultChanged, and the user's selection
with onTextSelectionChanged:
PDFView(
filePath: path,
onSearchResultChanged: (int index, int total) => ..., // index is -1 when cleared
onTextSelectionChanged: (String? text) => ..., // null when cleared
)
Stopping text from leaving the document (#108)
PDFView(
filePath: path,
enableTextSelection: false, // no long-press selection
enableCopy: false, // no copy / share / look-up in the edit menu
)
Both update at runtime without remounting the view. enableCopy needs a
selection to suppress, so enableTextSelection: false disables copying too.
On Android's default engine, enableCopy: false removes Copy, Copy link and the
smart actions from the selection menu. With flutter_pdfview_android_pdfium
both settings have no effect. Note that neither prevents screenshots, nor a user
extracting text from a copy of the file obtained elsewhere.
Detecting taps (onTap)
For a reliable single-tap callback, use the first-class onTap parameter. It
is delivered from the native PDF control on both platforms:
PDFView(
filePath: path,
onTap: () {
// e.g. toggle chrome / app bar
},
)
Do not rely on gestureRecognizers with a TapGestureRecognizer for taps.
Flutter’s platform-view gesture arena often never delivers onTap for embedded
native views (#133).
Keep gestureRecognizers for parent-scroll conflicts (below).
Using PDFView inside a scrollable widget
When a PDFView is embedded in a scrollable parent (SingleChildScrollView,
ListView, PageView, ...), the parent can claim drag gestures before they
reach the native view, so swiping inside the PDF does not work — most notably
on iOS (#265). Pass an
EagerGestureRecognizer to let the PDF view consume gestures within its bounds:
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
PDFView(
filePath: path,
gestureRecognizers: {
Factory<OneSequenceGestureRecognizer>(() => EagerGestureRecognizer()),
},
)
Render quality (#158)
iOS (PDFKit) draws PDF content as vectors at the screen scale. Text and line art
should stay sharp when zooming. This plugin sets the platform view’s
contentScaleFactor / layer contentsScale to the native display scale so
Flutter embedding never leaves the layer at 1×.
Android, default engine (androidx.pdf): rendering, tiling and caching are
managed by Android's own renderer; the knobs below do not apply.
Android, flutter_pdfview_android_pdfium (AndroidPdfViewer + Pdfium)
rasterizes each page into bitmap tiles:
| Knob | What it does | Cost |
|---|---|---|
useBestQuality: true (default) |
ARGB_8888 tiles instead of RGB_565 | ~2× bitmap memory vs 565 |
enableAntialiasing: true (default) |
FILTER_BITMAP / AA when drawing tiles |
Negligible |
enableRenderDuringScale: true (default) |
Re-render tiles during pinch zoom | More CPU while pinching |
thumbnailRatio (default 0.8) |
Resolution of the full-page preview shown before high-res tiles arrive | Memory ∝ ratio² |
On high-DPI devices the plugin also raises AndroidPdfViewer’s page-part cache slightly (still capped) so fewer tiles fall out of cache after zoom — the common “only part of the page is clear” report.
Hard limits (not a bug in this plugin):
- Tile spatial resolution matches the view size in pixels, not print DPI.
Small text on a phone-sized view will never look like a desktop PDF reader
without a different engine (supersampling / MuPDF / Android
PdfRendererat higher scale). That would multiply memory and is intentionally not enabled by default. - AndroidPdfViewer’s tile size / cache are process-wide statics;
thumbnailRatiofrom the first (or latest) view construction wins for the process.
For the sharpest Android preview without a huge memory hit:
PDFView(
filePath: path,
useBestQuality: true, // default
enableAntialiasing: true, // default
enableRenderDuringScale: true, // default
thumbnailRatio: 1.0, // full-page preview at 1:1 (more RAM)
)
AcroForm / fillable form fields
This plugin is a viewer, not a form editor. Platform behavior:
| Platform | Engine | Annotation / form field painting |
|---|---|---|
| Android | Android's PDF renderer (default, via androidx.pdf) or Pdfium (via AndroidPdfViewer in flutter_pdfview_android_pdfium) |
Widget appearance streams (/AP) are painted. Neither regenerates appearances from /V + /DA the way Adobe Reader does. |
| iOS | PDFKit | Uses the system renderer; typically more tolerant of incomplete appearances. |
Implication: if a PDF’s form field has a missing, empty, or broken /AP entry, Android can omit that field even when Adobe shows it. A common producer-side failure mode (seen with PDFBox + incremental saves / digital signing) is an object-number collision where the field’s /AP indirect reference is later reused for an XRef stream — the field value is still in the file, but the appearance object is no longer valid. See #303.
Producer workarounds (fix generators such as Apache PDFBox):
- After setting values, generate valid appearance streams (PDFBox:
setValue/ appearance generation; avoid leaving fields without a usable/AP). - Prefer a full rewrite save when possible; after incremental updates (especially signing), re-check that each field’s
/APstill resolves to a Form XObject, not an XRef or other object. - Flatten fields when interactivity is not required (
PDAcroForm.flatten()), so values become normal page content. - Optionally set
/NeedAppearances trueon the AcroForm dictionary — some viewers honor it; Pdfium generally still requires a real appearance stream for reliable display.
There is no plugin API that can repair malformed form appearances without embedding a full PDF rewrite stack (out of scope for this viewer).
BackdropFilter / ColorFiltered over PDFView (iOS)
PDFView is a platform view (UiKitView on iOS, hybrid composition on
Android). Flutter composites native views outside the normal Flutter layer
tree, so some widgets that sample or recolor the scene do not apply to the
PDF pixels — especially on iOS.
| Widget | iOS platform view | Notes |
|---|---|---|
ColorFiltered / ShaderMask |
❌ not supported | Official Flutter limitation |
BackdropFilter |
⚠️ partial | Supported with restrictions; needs a recent Flutter |
This is not a bug in flutter_pdfview. Flutter documents it under
iOS platform view composition limitations:
ShaderMask and ColorFiltered are unsupported; BackdropFilter works only
within the constraints of the
iOS Platform View Backdrop Filter design.
Workarounds
-
Color inversion / dark pages — Prefer the plugin API instead of wrapping the view in
ColorFiltered:- Both platforms:
colorMode: PdfColorMode.dark(orPdfColorMode.systemto follow the appTheme). Luminance-preserving invert keeps photos recognizable. - Legacy:
nightMode: truestill maps to dark whencolorModeis left atsystem(deprecated).
- Both platforms:
-
Blur / glass under a sheet — Place the
BackdropFilterso it samples Flutter-drawn content (not only the hole where the native PDF sits), use a semi-transparentbarrierColor/ scrim, or capture a static preview withPDFViewController.getScreenshotand blur thatImagewith Flutter widgets. -
Static filtered preview — For a one-shot recolor (e.g. thumbnail), take a screenshot and wrap the resulting image:
final path = await controller.getScreenshot('preview.png');
// Then:
ColorFiltered(
colorFilter: const ColorFilter.mode(Colors.grey, BlendMode.saturation),
child: Image.file(File(path)),
);
Wrapping PDFView itself in ColorFiltered will keep painting a solid tint
under the native view on iOS while leaving the PDF contents unchanged
(#213).
Full example
Basic viewer (password, color mode, layout). For a complete reader (page slider,
zoom, search, password prompt), see the example app's
ReaderScreen; its Playground shows every
option live, with the code for the current settings.
PDFView(
source: const PdfSource.asset('assets/manual.pdf'),
enableSwipe: true,
// Horizontal paging: iOS, and Android with flutter_pdfview_android_pdfium.
swipeHorizontal: true,
autoSpacing: false,
pageFling: false,
showScrollIndicators: true,
colorMode: PdfColorMode.system, // follows Theme brightness
backgroundColor: Theme.of(context).colorScheme.surface,
// Optional: inter-page gap when autoSpacing is true (dp / points).
// spacing: 12,
onRender: (_pages) {
setState(() {
pages = _pages;
isReady = true;
});
},
onError: (error) {
print(error.toString());
},
onPageError: (page, error) {
// Only the PDFium engine reports per-page errors.
print('$page: ${error.toString()}');
},
onViewCreated: (PDFViewController pdfViewController) async {
_controller.complete(pdfViewController);
// Only the PDFium engine animates; elsewhere withAnimation is ignored.
// await pdfViewController.setPage(2, withAnimation: true);
},
onPageChanged: (int page, int total) {
print('page change: $page/$total');
},
onLoadComplete: (int? pages) {
print('# of pages: $pages');
},
onDraw: (double xOffset, double yOffset, double scale) {
print('onDraw');
},
),
Text-layer sketch (always gate on support):
onViewCreated: (PDFViewController c) async {
if (!await c.isTextLayerSupported()) return;
final matches = await c.searchText('invoice');
// nextMatch / previousMatch / clearSearch …
},
onSearchResultChanged: (index, total) { /* highlight chrome */ },
onTextSelectionChanged: (text) { /* selection chrome */ },
enableTextSelection: true,
enableCopy: false, // hide copy / share / look-up in the selection menu
Migrating from 1.x
The Dart API and import path are unchanged, so most apps only need the platform setup above. Check these:
- Android minimum and SDK extension. Set
minSdkVersion 28andcompileSdkExtension 19(Platform setup), or addflutter_pdfview_android_pdfiumto keep the 1.x engine and Android 5.0+. - Pages follow your theme.
colorModedefaults toPdfColorMode.system, so a dark app theme now shows dark pages. PasscolorMode: PdfColorMode.lightfor the 1.x look.nightModestill works but is deprecated. - iOS applies settings changed on rebuild (
enableSwipe,colorMode,backgroundColor,password, zoom limits,pageAlignment,preventLinkNavigation). 1.x ignored them on iOS. - Android's default engine scrolls vertically only.
swipeHorizontal,pageFlingandpageSnapneed the PDFium engine, as do the PDFium quality settings andonPageError. - iOS 13 is the minimum.
- Optional: replace copy-the-asset-to-a-file code with
PdfSource.asset(...), and hand-rolled downloads withPdfSource.network(...).
The CHANGELOG lists every change.
Troubleshooting
Nothing shows, or the view stays blank. Add an onError callback first:
every engine reports why a document did not open (file not found, asset not
listed in pubspec.yaml, not a PDF, password needed, HTTP status).
Android build fails mentioning androidx.pdf, minSdkVersion or
compileSdkExtension. Apply the Android setup.
Swiping does not work inside a ListView, PageView or scroll view. The
parent claims the gesture first. See
Using PDFView inside a scrollable widget.
onTap on a GestureDetector around the PDF never fires. Use PDFView.onTap;
see Detecting taps.
A password-protected PDF does not open on an Android 9–10 device. The default
engine can only open protected files on Android 15, or Android 11+ with the PDF
system update; elsewhere onError says so. Add the PDFium engine if you need them
there.
searchText throws UnsupportedError. That device or engine has no text
layer. Check isTextLayerSupported() before showing search UI.
ColorFiltered, ShaderMask or BackdropFilter have no effect on iOS. This
is a Flutter platform-view limit; see
the workarounds.
Form fields are missing on Android. Usually a broken appearance stream in the PDF; see AcroForm / fillable form fields.
Limitations
- Viewer only: no annotation editing or form filling. Forms display, but values cannot be entered or saved.
- No built-in navigation UI: build page sliders and "go to page" with the controller (Navigating and zooming).
- PDF only.
- Mobile only: iOS and Android. The plugin is federated, so other platforms can be added as separate packages.
- Platform view: some Flutter effects do not apply to the native view on iOS (details).
How it is built
- iOS (13.0+): PDFKit, in Swift.
- Android (9.0+): Jetpack
androidx.pdf(pdf-viewer,pdf-document-service) on Android's own PDF renderer, in Kotlin. The opt-influtter_pdfview_android_pdfiumpackage uses AndroidPdfViewer (viacom.github.marain87:AndroidPdfViewer) and supports Android 5.0+. - Federated: both talk to Dart through
flutter_pdfview_platform_interface, which other platform implementations can build on.
Future plans
- Horizontal paging on the default Android engine, once
androidx.pdfsupports it - Text layer for
flutter_pdfview_android_pdfium(JNI shim over PdfiumFPDFText_*) - Other platforms (macOS, Windows, Linux, Web) through the federated interface
- Smoother zooming and page changes
- More integration tests and device coverage
Support
Star History
Developer
Libraries
- flutter_pdfview
- A Flutter plugin that renders PDF documents with the platform's native
viewer: PDFKit on iOS and Android's own PDF renderer (
androidx.pdf) on Android.








