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;
    _pendingDragOffset = Offset.zero;
    _lastPendingEventTimestamp = null;
    if (onStart != null) {
      invokeCallback<void>('onStart', () => onStart(DragStartDetails(
        sourceTimeStamp: timestamp,
        globalPosition: _initialPosition,
      )));
    }
    if (delta != Offset.zero && onUpdate != null) {
      final Offset deltaForDetails = _getDeltaForDetails(delta);
      invokeCallback<void>('onUpdate', () => onUpdate(DragUpdateDetails(
        sourceTimeStamp: timestamp,
        delta: deltaForDetails,
        primaryDelta: _getPrimaryValueFromOffset(delta),
        globalPosition: _initialPosition + deltaForDetails,
      )));
    }
  }
}