viewerOverlayBuilder property
Add overlays to the viewer.
This function is to generate widgets on PDF viewer's overlay Stack. The widgets can be layed out using layout widgets such as Positioned and Align.
The most typical use case is to add scroll thumbs to the viewer. The following fragment illustrates how to add vertical and horizontal scroll thumbs:
viewerOverlayBuilder: (context, size, handleLinkTap) => [
PdfViewerScrollThumb(
controller: controller,
orientation: ScrollbarOrientation.right),
PdfViewerScrollThumb(
controller: controller,
orientation: ScrollbarOrientation.bottom),
],
For more information, see PdfViewerScrollThumb.
Note for using GestureDetector inside viewerOverlayBuilder:
You may want to use GestureDetector inside viewerOverlayBuilder to handle certain gesture events. In such cases, your GestureDetector eats the gestures and the viewer cannot handle them directly. So, when you use GestureDetector inside viewerOverlayBuilder, please ensure the following things:
- GestureDetector.behavior should be HitTestBehavior.translucent
- GestureDetector.onTapUp (or such depending on your situation) should call
handleLinkTap
to handle link tap
The following fragment illustrates how to handle link tap in GestureDetector:
viewerOverlayBuilder: (context, size, handleLinkTap) => [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTapUp: (details) => handleLinkTap(details.localPosition),
// Make the GestureDetector covers all the viewer widget's area
// but also make the event go through to the viewer.
child: IgnorePointer(child: SizedBox(width: size.width, height: size.height)),
...
),
...
]
Implementation
final PdfViewerOverlaysBuilder? viewerOverlayBuilder;