PageView class
A widget that renders a single page of a PdfDocument.
PageView is a stateful widget that accepts a PdfDocument and a pageIndex. On build it calls PdfDocument.getPageSize to derive the aspect ratio, then PdfDocument.renderPageToBytes at the widget's full available width (fit-to-width). The logical width is multiplied by MediaQuery.devicePixelRatioOf to produce sharp output on high-DPI displays.
A CircularProgressIndicator is shown while the render is in flight. The last successfully rendered ui.Image is cached and reused to avoid re-rendering on cosmetic rebuilds. Re-rendering is triggered only when pageIndex changes or the available width changes by more than 2 logical pixels.
Example
PageView(
document: doc,
pageIndex: 0,
options: RenderOptions(renderAnnotations: false),
)
Resource management
The widget disposes each ui.Image it owns when it is replaced by a new render or when the widget is disposed. The PdfDocument itself is owned by the caller and is not closed by this widget.
Error handling
Render errors (RangeError, StateError, PdfiumException) are caught and displayed as a centred error message. The widget does not rethrow.
Accessibility
The rendered page canvas is wrapped in a Semantics widget labelled as an
image. Provide a meaningful semanticLabel when the document content is
known (e.g. the file name). Loading and error states are also labelled.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PageView
Constructors
Properties
- document → PdfDocument
-
The PDF document to render.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- options → RenderOptions
-
Options controlling how the page is rendered.
final
- pageIndex → int
-
The zero-based index of the page to display.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
A label describing the content of the rendered page for accessibility.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PageView> -
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