sweep method

void sweep (int pointer)

Forces resolution of the arena, giving the win to the first member.

Sweep is typically after all the other processing for a PointerUpEvent have taken place. It ensures that multiple passive gestures do not cause a stalemate that prevents the user from interacting with the app.

Recognizers that wish to delay resolving an arena past PointerUpEvent should call hold to delay sweep until release is called.

See also:

Implementation

void sweep(int pointer) {
  final _GestureArena state = _arenas[pointer];
  if (state == null)
    return; // This arena either never existed or has been resolved.
  assert(!state.isOpen);
  if (state.isHeld) {
    state.hasPendingSweep = true;
    assert(_debugLogDiagnostic(pointer, 'Delaying sweep', state));
    return; // This arena is being held for a long-lived member.
  }
  assert(_debugLogDiagnostic(pointer, 'Sweeping', state));
  _arenas.remove(pointer);
  if (state.members.isNotEmpty) {
    // First member wins.
    assert(_debugLogDiagnostic(pointer, 'Winner: ${state.members.first}'));
    state.members.first.acceptGesture(pointer);
    // Give all the other members the bad news.
    for (int i = 1; i < state.members.length; i++)
      state.members[i].rejectGesture(pointer);
  }
}