SearchView class
A search input panel with result list for a PDF document.
SearchView shows a text field; when the query reaches minQueryLength characters it auto-searches after a 300 ms debounce. For shorter queries, search triggers on Enter or focus-leave. Results are displayed as cards sorted by page order, each showing the surrounding text context with the match highlighted in a translucent amber-tinted span.
Matches are forwarded to ViewerController.setSearchMatches so PageViewer can draw overlay highlights. Clearing the search calls ViewerController.clearSearch.
Live region
The results count node has liveRegion: true so screen readers announce
updates as results arrive.
Example
SearchView(
document: doc,
controller: controller,
hintText: l10n.searchHint,
clearLabel: l10n.searchClear,
resultsCountBuilder: (count) => l10n.searchResultsCount(count),
noResultsText: l10n.searchNoResults,
resultPageBuilder: (n) => l10n.searchResultPage(n),
sectionResolver: (pageIndex) => tocSectionFor(pageIndex),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SearchView
Constructors
- SearchView({Key? key, required PdfDocument document, required ViewerController controller, required String hintText, required String clearLabel, required String resultsCountBuilder(int count), required String noResultsText, required String resultPageBuilder(int count), String? sectionResolver(int pageIndex)?, int minQueryLength = 3})
-
Creates a SearchView.
const
Properties
- clearLabel → String
-
Accessible label for the clear (×) button.
final
- controller → ViewerController
-
The controller that receives active search matches.
final
- document → PdfDocument
-
The PDF document to search.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String
-
Placeholder text for the search input field.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- minQueryLength → int
-
Minimum query length for auto-triggering a search on keystroke.
final
- noResultsText → String
-
Text shown when a completed search returns no matches.
final
- resultPageBuilder → String Function(int count)
-
Builds the localised page label for a result card (e.g. "Page 5").
final
- resultsCountBuilder → String Function(int count)
-
Builds the localised results-count string (e.g. "3 results").
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sectionResolver → String? Function(int pageIndex)?
-
Optional function that resolves a zero-based pageIndex to the TOC
section name that contains that page.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SearchView> -
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