onDragStart method

  1. @mustCallSuper
void onDragStart(
  1. DragStartEvent event
)

Called when the user initiates a drag gesture, for example by touching the screen and then moving the finger.

The handler propagates the event to any component located at the point of touch and that uses the DragCallbacks mixin. The event will be first delivered to the topmost such component, and then propagated to the components below only if explicitly requested.

Each event has an event.pointerId to keep track of multiple touches that may occur simultaneously.

A component that sets DragCallbacks.allowsMultiPointerDrag to false is skipped while it already has a drag in progress, and the event carries on to the components below it.

Implementation

@mustCallSuper
void onDragStart(DragStartEvent event) {
  event.deliverAtPoint(
    rootComponent: gameRef,
    eventHandler: (DragCallbacks component) {
      if (!component.allowsMultiPointerDrag && _isDragging(component)) {
        event.continuePropagation = true;
        return;
      }
      _records.add(TaggedComponent(event.pointerId, component));
      component.onDragStart(event);
    },
  );
}