flingAnimatedRaw method

void flingAnimatedRaw({
  1. required double velocity,
  2. required Offset direction,
  3. required Offset begin,
  4. Offset offset = Offset.zero,
  5. double mass = 1,
  6. double stiffness = 1000,
  7. double ratio = 5,
  8. required bool hasGesture,
})

Fling animation for the map. The raw method allows to set all parameters.

Implementation

void flingAnimatedRaw({
  required double velocity,
  required Offset direction,
  required Offset begin,
  Offset offset = Offset.zero,
  double mass = 1,
  double stiffness = 1000,
  double ratio = 5,
  required bool hasGesture,
}) {
  // cancel all ongoing animation
  _animationController.stop();
  _resetAnimations();

  _animationHasGesture = hasGesture;
  _animationOffset = offset;
  _flingMapCenterStartPoint = camera.projectAtZoom(camera.center);

  final distance = (Offset.zero & camera.nonRotatedSize).shortestSide;

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

  _animationController.value = 0;
  _animationController.fling(
    velocity: velocity,
    springDescription: SpringDescription.withDampingRatio(
      mass: mass,
      stiffness: stiffness,
      ratio: ratio,
    ),
  );
}