handleEvent method

  1. @override
void handleEvent (
  1. PointerEvent event
)
override

Called when a pointer event is routed to this recognizer.

Implementation

@override
void handleEvent(PointerEvent event) {
  assert(_state != _ScaleState.ready);
  bool didChangeConfiguration = false;
  bool shouldStartIfAccepted = false;
  if (event is PointerMoveEvent) {
    final VelocityTracker tracker = _velocityTrackers[event.pointer];
    assert(tracker != null);
    if (!event.synthesized) tracker.addPosition(event.timeStamp, event.position);
    _pointerLocations[event.pointer] = event.position;
    shouldStartIfAccepted = true;

    pointCount = _pointerLocations.keys.length;
    if (pointCount <= 1 && onUpdate != null && isOnlyOnePoint && !isFirstTap)
      invokeCallback<void>(
          'onUpdate',
          () => onUpdate(ScaleUpdateDetails(
              scale: _scaleFactor,
              focalPoint: _currentFocalPoint,
              rotation: _computeRotationFactor(),
              pointerEvent: event,
              pointCount: pointCount)));
  } else if (event is PointerDownEvent) {
    isOnlyOnePoint = _pointerQueue.length == 0;

    _pointerLocations[event.pointer] = event.position;
    _pointerQueue.add(event.pointer);
    didChangeConfiguration = true;
    shouldStartIfAccepted = true;
  } else if (event is PointerUpEvent || event is PointerCancelEvent) {
    _pointerLocations.remove(event.pointer);
    _pointerQueue.remove(event.pointer);
    didChangeConfiguration = true;
  }
  _updateLines();
  _update();

  if (!didChangeConfiguration || _reconfigure(event.pointer)) {
    _advanceStateMachine(shouldStartIfAccepted, event);
  }
  stopTrackingIfPointerNoLongerDown(event);
}