GestureEvent.fromPointerEvent constructor

GestureEvent.fromPointerEvent(
  1. PointerEvent event, {
  2. required Vector2 screenToWorld(
    1. Vector2 position
    ),
  3. required Vector2 globalToViewportPosition(
    1. Vector2 position
    ),
})

Implementation

factory GestureEvent.fromPointerEvent(
  PointerEvent event, {
  required Vector2 Function(Vector2 position) screenToWorld,
  required Vector2 Function(Vector2 position) globalToViewportPosition,
}) {
  final eventPosition = event.localPosition.toVector2();
  final screenPosition = globalToViewportPosition(eventPosition);
  return GestureEvent(
    pointer: event.pointer,
    kind: event.kind,
    screenPosition: screenPosition,
    worldPosition: screenToWorld(eventPosition),
  );
}