handlePointerEvent method Null safety
- PointerEvent event
override
Dispatch an event to the targets found by a hit test on its position.
If the pointerEventSource is TestBindingEventSource.test, then the event is forwarded to GestureBinding.dispatchEvent as usual; additionally, down pointers are painted on the screen.
If the pointerEventSource is TestBindingEventSource.device, then the event, after being transformed to the local coordinate system, is forwarded to deviceEventDispatcher.
Implementation
@override
void handlePointerEvent(PointerEvent event) {
switch (pointerEventSource) {
case TestBindingEventSource.test:
final _LiveTestPointerRecord? record = _liveTestRenderView._pointers[event.pointer];
if (record != null) {
record.position = event.position;
if (!event.down) {
record.decay = _kPointerDecay;
}
_handleViewNeedsPaint();
} else if (event.down) {
_liveTestRenderView._pointers[event.pointer] = _LiveTestPointerRecord(
event.pointer,
event.position,
);
_handleViewNeedsPaint();
}
super.handlePointerEvent(event);
break;
case TestBindingEventSource.device:
if (deviceEventDispatcher != null) {
// The pointer events received with this source has a global position
// (see [handlePointerEventForSource]). Transform it to the local
// coordinate space used by the testing widgets.
final PointerEvent localEvent = event.copyWith(position: globalToLocal(event.position));
withPointerEventSource(TestBindingEventSource.device,
() => super.handlePointerEvent(localEvent)
);
}
break;
}
}