onDragUpdate method

  1. @mustCallSuper
void onDragUpdate(
  1. DragUpdateEvent event
)

Called continuously during the drag as the user moves their finger.

The default handler propagates this event to those components who received the initial onDragStart event. If the position of the pointer is outside of the bounds of the component, then this event will nevertheless be delivered, however its event.localPosition property will contain NaNs.

Implementation

@mustCallSuper
void onDragUpdate(DragUpdateEvent event) {
  final updated = <TaggedComponent<DragCallbacks>>{};
  event.deliverAtPoint(
    rootComponent: game,
    deliverToAll: true,
    eventHandler: (DragCallbacks component) {
      final record = TaggedComponent(event.pointerId, component);
      if (_records.contains(record)) {
        component.onDragUpdate(event);
        updated.add(record);
      }
    },
  );
  for (final record in _records) {
    if (record.pointerId == event.pointerId && !updated.contains(record)) {
      record.component.onDragUpdate(event);
    }
  }
}