animatedMapMove function

void animatedMapMove(
  1. MapController? mapController,
  2. AnimationController animationController,
  3. LatLng destLocation,
  4. double destZoom,
)

Implementation

void animatedMapMove(
  MapController? mapController,
  AnimationController animationController,
  LatLng destLocation,
  double destZoom,
) {
  final latTween = Tween<double>(
    begin: mapController!.center.latitude,
    end: destLocation.latitude,
  );

  final lngTween = Tween<double>(
    begin: mapController.center.longitude,
    end: destLocation.longitude,
  );

  final zoomTween = Tween<double>(
    begin: mapController.zoom,
    end: destZoom,
  );

  final Animation<double> animation = CurvedAnimation(
    parent: animationController,
    curve: Curves.fastOutSlowIn,
  );

  // TODO(amaru): We need to deactivate any action button when we are animating the map.
  animationController
    ..reset()
    ..addListener(() {
      mapController.move(
        LatLng(
          latTween.evaluate(animation),
          lngTween.evaluate(animation),
        ),
        zoomTween.evaluate(animation),
      );
    })
    ..forward();

  //animationController.addStatusListener((status) {
  //  if (status == AnimationStatus.completed) {
  //    // animationController.removeListener(() {});
  //    // animationController.dispose();
  //    // animationController.reset();
  //  } else if (status == AnimationStatus.dismissed) {
  //    // animationController.removeListener(mapMove);
  //    // animationController.reset();
  //  }
  //});

  //animationController.forward();
}