acceptGesture method

  1. @override
void acceptGesture (int pointer)
override

Called when this member wins the arena for the given pointer id.

Implementation

@override
void acceptGesture(int pointer) {
  if (_state != _DragState.accepted) {
    _state = _DragState.accepted;
    final Offset delta = _pendingDragOffset;
    final Duration timestamp = _lastPendingEventTimestamp;
    Offset updateDelta;
    switch (dragStartBehavior) {
      case DragStartBehavior.start:
        _initialPosition = _initialPosition + delta;
        updateDelta = Offset.zero;
        break;
      case DragStartBehavior.down:
        updateDelta = _getDeltaForDetails(delta);
        break;
    }
    _pendingDragOffset = Offset.zero;
    _lastPendingEventTimestamp = null;
    if (onStart != null) {
      invokeCallback<void>('onStart', () => onStart(DragStartDetails(
        sourceTimeStamp: timestamp,
        globalPosition: _initialPosition,
      )));
    }
    if (updateDelta != Offset.zero && onUpdate != null) {
      invokeCallback<void>('onUpdate', () => onUpdate(DragUpdateDetails(
        sourceTimeStamp: timestamp,
        delta: updateDelta,
        primaryDelta: _getPrimaryValueFromOffset(updateDelta),
        globalPosition: _initialPosition + updateDelta, // Only adds delta for down behaviour
      )));
    }
  }
}