TocView class

A scrollable Table of Contents widget for a PDF document.

TocView renders a List<PdfTocEntry> as a nested scrollable list. Tapping an entry that has a PdfTocEntry.pageIndex navigates the viewer to that page via ViewerController.setPage. Entries without a page index (section labels or URI-only entries) are displayed in a muted style and are not interactive.

Accessibility

Each interactive row is wrapped in Semantics with button: true and a label of "${entry.title}, page ${entry.pageIndex + 1}". Non-interactive section-label rows use a plain text label.

Empty state

When entries is empty, a centred placeholder text is shown. Provide the emptyText to localise this message (required — pass from ARB).

Example

TocView(
  entries: toc,
  controller: controller,
  pageCount: doc.pageCount,
  emptyText: l10n.tocEmpty,
)
Inheritance

Constructors

TocView({Key? key, required List<PdfTocEntry> entries, required ViewerController controller, required int pageCount, required String emptyText})
Creates a TocView.
const

Properties

controller → ViewerController
The controller that drives page navigation and reports the current page for active-entry highlighting.
final
emptyText → String
Text shown when entries is empty.
final
entries → List<PdfTocEntry>
The Table of Contents entries to display (root-level; children are nested automatically).
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
pageCount → int
Total number of pages in the document — passed to setPage for range clamping.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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