dispatchPointerEvent method
- PointerEvent event
override
Converts the PointerEvent and sends an Android MotionEvent to the view.
This method can only be used if a PointTransformer is provided to
AndroidViewController.pointTransformer. Otherwise, an AssertionError
is thrown. See AndroidViewController.sendMotionEvent for sending a
MotionEvent
without a PointTransformer.
The Android MotionEvent object is created with MotionEvent.obtain. See documentation of MotionEvent.obtain for description of the parameters.
Implementation
@override
Future<void> dispatchPointerEvent(PointerEvent event) async {
if (event is PointerHoverEvent) {
return;
}
if (event is PointerDownEvent) {
_motionEventConverter.handlePointerDownEvent(event);
}
_motionEventConverter.updatePointerPositions(event);
final AndroidMotionEvent? androidEvent =
_motionEventConverter.toAndroidMotionEvent(event);
if (event is PointerUpEvent) {
_motionEventConverter.handlePointerUpEvent(event);
} else if (event is PointerCancelEvent) {
_motionEventConverter.handlePointerCancelEvent(event);
}
if (androidEvent != null) {
await sendMotionEvent(androidEvent);
}
}