handleScaleEnd method

void handleScaleEnd(
  1. ScaleEndDetails details
)

Implementation

void handleScaleEnd(ScaleEndDetails details) {
  _resetDoubleTapHold();

  var magnitude = details.velocity.pixelsPerSecond.distance;
  if (magnitude < _kMinFlingVelocity) {
    return;
  }

  var direction = details.velocity.pixelsPerSecond / magnitude;
  var distance = (Offset.zero & context.size!).shortestSide;

  // correct fling direction with rotation
  var v = Matrix4.rotationZ(-degToRadian(mapState!.rotation)) *
      Vector4(direction.dx, direction.dy, 0, 0);
  direction = Offset(v.x, v.y);

  _flingAnimation = Tween<Offset>(
    begin: _flingOffset,
    end: _flingOffset - direction * distance,
  ).animate(_controller!);

  _controller!
    ..value = 0.0
    ..fling(velocity: magnitude / 1000.0);
}