WordController class
Loads a Word (.docx) document for WordView: its layout
(viewMode), zoom, search, the page in view and the scroll position.
Bytes pass ZipSafetyGuard and are parsed off the UI isolate. In print
layout, location counts pages; reflowed, it's how far through the
document the reader is, in percent. The position is
{scroll_offset, view_mode, paragraph}: the offset belongs to that
layout, and paragraph (the paragraph at the top) lets a thumbnail show
the page the reader left off on.
- Inheritance
-
- Object
- ChangeNotifier
- DocumentController
- WordController
Constructors
-
WordController({ReadingPosition? initialPosition, ValueChanged<
ReadingPosition> ? onPositionChanged}) -
Reopens in the layout and at the offset saved in
initialPosition, if any.
Properties
- canZoomIn → bool
-
Whether zoomIn would zoom in.
no setterinherited
- canZoomOut → bool
-
Whether zoomOut would zoom out.
no setterinherited
- document → WordDocument?
-
The parsed document; null until loaded.
no setter
- error → DocumentLoadError?
-
Why the document couldn't be loaded; null unless status is
DocumentStatus.failed.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
hasSelection
→ ValueListenable<
bool> -
Whether the reader has text selected, for enabling a Copy button
without rebuilding on every other change.
no setterinherited
- initialScrollOffset ↔ double
-
Where the document scrolls to once shown. Settable until then.
getter/setter pair
- isDisposed → bool
-
Whether dispose has been called. A load that finishes afterwards
discards its result.
no setterinherited
- isLoaded → bool
-
True once loading has finished, successfully or not.
no setterinherited
-
location
→ ValueListenable<
DocumentLocation> -
Where the reader is, updated as they move: listen to it for a "page 3
of 12" display without rebuilding on every other change.
no setterinherited
- maxFileBytes → int
-
The largest file loadFile reads. Bigger files fail with
DocumentLoadError.tooLarge before anything is read.
no setterinherited
- maxZoom → double
-
The largest zoom.
no setteroverride
- minZoom → double
-
The smallest zoom.
no setteroverride
-
onPositionChanged
→ ValueChanged<
ReadingPosition> ? -
Called as the reader moves through the document, with the position
to save. Debouncing and storage are up to the app.
finalinherited
- pageCount → int?
-
The number of pages in print layout; null when reflowed, which has no
pages.
no setter
- position → ReadingPosition
-
The place to save, as JSON-safe values: pass it back as
initialPositionto reopen there.no setteroverride - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
searchState
→ ValueListenable<
DocumentSearchState> -
The current search, updated as it runs and as the reader steps
through its matches.
no setterinherited
- status → DocumentStatus
-
Whether the document is loading, ready or failed.
no setterinherited
- viewMode ↔ WordViewMode
-
Reflowed or print layout.
getter/setter pair
- zoom → double
-
How large the document is drawn: reflowed, the text reflows at this
scale; in print layout, the pages scale (panning sideways when wider
than the view).
no setteroverride
- zoomStep → double
-
How much zoomIn and zoomOut change zoom by.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
allText(
) → Future< String> -
The document's whole text, for "copy all". Empty for a format with no
text to give (a scanned PDF, until it has been recognised).
override
-
clearSearch(
) → void -
Ends the search and removes its highlights.
override
-
clearSelection(
) → void -
Clears the selection. Does nothing until a view is showing the
document.
inherited
-
copyAllText(
) → Future< bool> -
Puts allText on the clipboard; false when the document has no text
or the clipboard refused it.
inherited
-
copySelection(
) → Future< bool> -
Puts selectedText on the clipboard. Returns false when nothing is
selected or the clipboard refused it, so the app can say so.
inherited
-
copyToClipboard(
String text) → Future< bool> -
Writes
textto the clipboard; false when it isn't available.inherited -
deferGoTo(
int number) → void -
For a format's controller: goTo can't move yet (the document isn't
loaded, or no view has laid it out), so
numberis kept untilapplyPending.inherited -
dispose(
) → void -
Discards any resources used by the object.
override
-
goTo(
int number) → void -
Shows page
number(from 1) in print layout; reflowed, scrollsnumberpercent of the way through.override -
loadBytes(
Uint8List bytes) → Future< void> -
Checks
byteswith ZipSafetyGuard, then parses them in a background isolate.override -
loadFile(
String path) → Future< void> -
Loads the document at
path.inherited -
markFailed(
DocumentLoadError error) → void -
For a format's controller, or an app whose own read of the file
failed: the document can't be shown, because of
error.inherited -
markLoading(
) → void -
For a format's controller: loading has started.
inherited
-
markReady(
) → void -
For a format's controller: the document is loaded.
inherited
-
nextMatch(
) → void -
Shows the next match, wrapping round after the last.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
previousMatch(
) → void -
Shows the previous match, wrapping round before the first.
override
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
reportPosition(
) → void -
Reports position to onPositionChanged.
inherited
-
restore(
ReadingPosition position) → void - Applies a saved position: the layout and the offset in it. For an app that reads the position after creating the controller; call before the view is shown.
-
search(
String query) → void -
Finds every occurrence of
query(ignoring case) in the body, tables, headers, footers and notes, and shows the first.override -
selectAll(
) → void -
Selects everything the view has laid out: all of a spreadsheet's used
range, but only the pages or lines built so far in a long text
document; use allText to copy a whole document.
inherited
-
selectedText(
) → String? -
What the reader has selected, as the text to paste; null when nothing
is selected. PDF, Word, plain text, Markdown and slides give the
selected words; a spreadsheet gives its cells as tab-separated rows.
inherited
-
setHasSelection(
bool value) → void -
For a format that works out its selected text on demand (selectedText
being costly): there is, or isn't, a selection.
inherited
-
setZoom(
double zoom) → void -
Sets
zoom, clamped to minZoom..maxZoom.override -
toggleViewMode(
) → void - Switches between WordViewMode.continuous and WordViewMode.paged.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateLocation(
DocumentLocation location) → void -
For a format's controller: the reader is now at
location.inherited -
updateSearch(
DocumentSearchState state) → void -
For a format's controller: the search is now
state.inherited -
zoomIn(
) → void -
Zooms in one step.
inherited
-
zoomOut(
) → void -
Zooms out one step.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited