PdfFlipBook class
A PDF shown as a book with the corner-curl page turn of PageFlipView.
Pages are rendered with pdfrx (PDFium) in a background isolate: a small preview appears at once, then the page is sharpened to screen resolution. The pages around the current one are rendered ahead of time, so turning pages does not show a spinner.
PdfFlipBook.network(Uri.parse('https://example.com/book.pdf'))
PdfFlipBook.asset('assets/book.pdf')
PdfFlipBook.file('/path/book.pdf')
PdfFlipBook.data(bytes)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PdfFlipBook
Constructors
-
PdfFlipBook.asset(String name, {Key? key, PageFlipController? controller, ValueChanged<
int> ? onPageChanged, ValueChanged<int> ? onLoaded, VoidCallback? onCenterTap, Color paperColor = const Color(0xFFFFFFFF), PdfLoadingBuilder? loadingBuilder, PdfPagePlaceholderBuilder? placeholderBuilder, PdfPageErrorBuilder? pageErrorBuilder, PdfDocumentErrorBuilder? errorBuilder, String? password, ColorFilter? colorFilter, bool enableZoom = true, bool enableTapToFlip = true, double maxScale = 4, PageSpreadMode spreadMode = PageSpreadMode.auto, bool coverAlone = true}) -
Opens the PDF bundled as the Flutter asset
name.const -
PdfFlipBook.data(Uint8List data, {Key? key, PageFlipController? controller, ValueChanged<
int> ? onPageChanged, ValueChanged<int> ? onLoaded, VoidCallback? onCenterTap, Color paperColor = const Color(0xFFFFFFFF), PdfLoadingBuilder? loadingBuilder, PdfPagePlaceholderBuilder? placeholderBuilder, PdfPageErrorBuilder? pageErrorBuilder, PdfDocumentErrorBuilder? errorBuilder, String? password, ColorFilter? colorFilter, bool enableZoom = true, bool enableTapToFlip = true, double maxScale = 4, PageSpreadMode spreadMode = PageSpreadMode.auto, bool coverAlone = true}) -
Opens a PDF from memory, for example after downloading or decrypting it.
const
-
PdfFlipBook.document(PdfDocument document, {Key? key, PageFlipController? controller, ValueChanged<
int> ? onPageChanged, ValueChanged<int> ? onLoaded, VoidCallback? onCenterTap, Color paperColor = const Color(0xFFFFFFFF), PdfPagePlaceholderBuilder? placeholderBuilder, PdfPageErrorBuilder? pageErrorBuilder, ColorFilter? colorFilter, bool enableZoom = true, bool enableTapToFlip = true, double maxScale = 4, PageSpreadMode spreadMode = PageSpreadMode.auto, bool coverAlone = true}) -
Shows a
PdfDocumentyou already opened with pdfrx. The caller keeps ownership and disposes it.const -
PdfFlipBook.file(String path, {Key? key, PageFlipController? controller, ValueChanged<
int> ? onPageChanged, ValueChanged<int> ? onLoaded, VoidCallback? onCenterTap, Color paperColor = const Color(0xFFFFFFFF), PdfLoadingBuilder? loadingBuilder, PdfPagePlaceholderBuilder? placeholderBuilder, PdfPageErrorBuilder? pageErrorBuilder, PdfDocumentErrorBuilder? errorBuilder, String? password, ColorFilter? colorFilter, bool enableZoom = true, bool enableTapToFlip = true, double maxScale = 4, PageSpreadMode spreadMode = PageSpreadMode.auto, bool coverAlone = true}) -
Opens the PDF at
pathon the device.const -
PdfFlipBook.network(Uri uri, {Key? key, Map<
String, String> ? headers, Duration? timeout, PageFlipController? controller, ValueChanged<int> ? onPageChanged, ValueChanged<int> ? onLoaded, VoidCallback? onCenterTap, Color paperColor = const Color(0xFFFFFFFF), PdfLoadingBuilder? loadingBuilder, PdfPagePlaceholderBuilder? placeholderBuilder, PdfPageErrorBuilder? pageErrorBuilder, PdfDocumentErrorBuilder? errorBuilder, String? password, ColorFilter? colorFilter, bool enableZoom = true, bool enableTapToFlip = true, double maxScale = 4, PageSpreadMode spreadMode = PageSpreadMode.auto, bool coverAlone = true}) -
Downloads and opens the PDF at
uri. Passheadersfor authenticated URLs. The download progress is given toloadingBuilder.const
Properties
- colorFilter → ColorFilter?
-
Colour filter applied to every rendered page.
final
- controller → PageFlipController?
-
Turns pages from code; see PageFlipController.
final
- coverAlone → bool
-
In two-page mode, whether the first page stands alone on the right,
like the cover of a printed book.
final
- enableTapToFlip → bool
-
Whether tapping the left or right edge of a page turns it. Turn off to
keep every tap for onCenterTap, for example to show reader controls;
dragging still turns pages.
final
- enableZoom → bool
-
Pinch or double tap to zoom into a page. The zoomed page is rendered
again at the higher resolution, so text stays sharp.
final
- errorBuilder → PdfDocumentErrorBuilder?
-
Shown when the document cannot be opened. Defaults to a retry button.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingBuilder → PdfLoadingBuilder?
-
Shown while the document opens or downloads. Defaults to a progress
indicator that fills up while a network file downloads.
final
- maxScale → double
-
Largest zoom factor.
final
- onCenterTap → VoidCallback?
-
Called on a tap in the middle of the page.
final
-
onLoaded
→ ValueChanged<
int> ? -
Called once with the page count when the document is open.
final
-
onPageChanged
→ ValueChanged<
int> ? -
Called with the zero-based page index after each turn or jump.
final
- pageErrorBuilder → PdfPageErrorBuilder?
-
Shown on a page whose rendering failed. Defaults to plain paper.
final
- paperColor → Color
-
Colour of the paper: behind each page until it is rendered, and on the
back of a turning sheet in single-page mode.
final
- password → String?
-
Password for encrypted PDFs.
final
- placeholderBuilder → PdfPagePlaceholderBuilder?
-
Shown on a page until its first preview is ready. Defaults to plain
paper, which is usually only visible for a split second.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spreadMode → PageSpreadMode
-
One page, two pages side by side, or PageSpreadMode.auto: two pages
when the space is wide (landscape, tablets, unfolded foldables such as
the Galaxy Z Fold, where the spine lands on the fold). The book
switches live when the device rotates or folds, keeping the page.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PdfFlipBook> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- dim → const ColorFilter
- A colorFilter that darkens the page to 75 % brightness and keeps every colour, so covers and pictures stay correct. Good for reading in a dark room. Pair it with dimPaper as paperColor.
- dimPaper → const Color
- Paper colour for dim: white at 75 % brightness.
- nightMode → const ColorFilter
- A colorFilter that inverts every colour of the page: black text on white becomes light text on black.
- nightPaper → const Color
- Paper colour for nightMode: white inverted.
- sepia → const ColorFilter
- A colorFilter that gives the page a warm, cream paper tone, easier on the eyes than bright white. Pictures keep their colours but look warmer. Pair it with sepiaPaper as paperColor.
- sepiaPaper → const Color
- Paper colour for sepia: white seen through the sepia filter.