handleScaleEnd method

void handleScaleEnd(
  1. ScaleEndDetails details
)
inherited

Implementation

void handleScaleEnd(ScaleEndDetails details) {
  _resetDoubleTapHold();

  final eventSource =
      _dragMode ? MapEventSource.dragEnd : MapEventSource.multiFingerEnd;

  if (_rotationStarted) {
    _rotationStarted = false;
    mapState.emitMapEvent(
      MapEventRotateEnd(
        center: mapState.center,
        zoom: mapState.zoom,
        source: eventSource,
      ),
    );
  }

  if (_dragStarted || _pinchZoomStarted || _pinchMoveStarted) {
    _dragStarted = _pinchZoomStarted = _pinchMoveStarted = false;
    mapState.emitMapEvent(
      MapEventMoveEnd(
        center: mapState.center,
        zoom: mapState.zoom,
        source: eventSource,
      ),
    );
  }

  final hasFling = InteractiveFlag.hasFlag(
      options.interactiveFlags, InteractiveFlag.flingAnimation);

  final magnitude = details.velocity.pixelsPerSecond.distance;
  if (magnitude < _kMinFlingVelocity || !hasFling) {
    if (hasFling) {
      mapState.emitMapEvent(
        MapEventFlingAnimationNotStarted(
          center: mapState.center,
          zoom: mapState.zoom,
          source: eventSource,
        ),
      );
    }

    return;
  }

  final direction = details.velocity.pixelsPerSecond / magnitude;
  final distance = (Offset.zero &
          Size(mapState.nonrotatedSize.x, mapState.nonrotatedSize.y))
      .shortestSide;

  final flingOffset = _focalStartLocal - _lastFocalLocal;
  _flingAnimation = Tween<Offset>(
    begin: flingOffset,
    end: flingOffset - direction * distance,
  ).animate(_flingController);

  _flingController
    ..value = 0.0
    ..fling(
        velocity: magnitude / 1000.0,
        springDescription: SpringDescription.withDampingRatio(
          mass: 1,
          stiffness: 1000,
          ratio: 5,
        ));
}