pageTextMatchPaintCallback method
Paint callback to highlight the matches.
Use this with PdfViewerParams.pagePaintCallback
to highlight the matches.
Implementation
void pageTextMatchPaintCallback(
ui.Canvas canvas, Rect pageRect, PdfPage page) {
final range = getMatchesRangeForPage(page.pageNumber);
if (range == null) return;
for (int i = range.start; i < range.end; i++) {
final m = _matches[i];
final rect = m.bounds
.toRect(page: page, scaledTo: pageRect.size)
.translate(pageRect.left, pageRect.top);
canvas.drawRect(
rect,
Paint()
..color = m == _currentMatch
? Colors.orange.withOpacity(0.5)
: Colors.yellow.withOpacity(0.5),
);
}
}