build method
Build the Widget. Instead of overriding this function, override buildChild so that all gesture detectors can be set up automatically.
Implementation
@override
Widget build(BuildContext context) {
ScrollbarControllerEncapsulation? scrollbarController =
this.scrollbarController;
scrollbarController?.updateScrollbarPainters();
Widget child = buildChild(context);
child = buildTransformAndScrollbars(context, child);
if (scrollbarController != null) {
child = RawGestureDetector(
gestures: scrollbarController.getGesturesVertical(context),
child: MouseRegion(
onExit: (PointerExitEvent event) {
switch (event.kind) {
case PointerDeviceKind.mouse:
case PointerDeviceKind.trackpad:
if (scrollbarController.enableGestures) {
scrollbarController.handleHoverExit(event);
}
case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown:
case PointerDeviceKind.touch:
break;
}
},
onHover: (PointerHoverEvent event) {
switch (event.kind) {
case PointerDeviceKind.mouse:
case PointerDeviceKind.trackpad:
if (scrollbarController.enableGestures) {
scrollbarController.handleHover(event);
}
case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown:
case PointerDeviceKind.touch:
break;
}
},
child: child,
),
);
child = RawGestureDetector(
gestures: scrollbarController.getGesturesHorizontal(context),
child: child,
);
}
if (!widget.noMouseDragScroll) {
child = GestureDetector(
behavior: HitTestBehavior.opaque,
// Necessary when panning off screen.
onScaleEnd: (onScaleEnd),
onScaleStart: onScaleStart,
onScaleUpdate: onScaleUpdate,
onDoubleTapDown:
widget.doubleTapToZoom ? ((d) => doubleTapDetails = d) : null,
onDoubleTap: widget.doubleTapToZoom ? handleDoubleTap : null,
child: child,
);
} else {
child = GestureDetector(
behavior: HitTestBehavior.opaque,
supportedDevices: const {
PointerDeviceKind.touch,
PointerDeviceKind.trackpad,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.unknown,
},
onScaleEnd: onScaleEnd,
onScaleStart: onScaleStart,
onScaleUpdate: onScaleUpdate,
child: child,
);
child = GestureDetector(
behavior: HitTestBehavior.opaque,
onScaleEnd: (d) {
onScaleEnd(d, outer: true);
},
onScaleStart: onScaleStart,
onScaleUpdate: (d) {
onScaleUpdate(d, inner: true);
},
onDoubleTapDown:
widget.doubleTapToZoom ? ((d) => doubleTapDetails = d) : null,
onDoubleTap: widget.doubleTapToZoom ? handleDoubleTap : null,
child: child,
);
}
return Listener(
key: parentKey,
onPointerSignal: receivedPointerSignal,
child: child,
);
}