move method
Implementation
Future<void> move(dynamic center, double? zoom,
[bool animate = false]) async {
log('MapStates move $center $zoom');
if (center is String) {
center = await findLocation(center);
} else {
center = LatLng.from(center);
}
if (center == null) {
return;
}
if (animate) {
_moveAnim = CurvedAnimationController.tween(
LatLngTween(begin: _center, end: center),
const Duration(milliseconds: 300),
curve: Curves.ease,
vsync: _vsync,
);
_zoomAnim = CurvedAnimationController(
begin: _zoom,
end: zoom,
duration: const Duration(milliseconds: 300),
curve: Curves.ease,
vsync: _vsync,
);
_moveAnim?.addListener(() {
_move(_moveAnim!.value, _zoom);
});
_zoomAnim?.addListener(() {
_zoom = _zoomAnim!.value;
});
_moveAnim?.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_moveAnim?.dispose();
}
});
_zoomAnim?.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_zoomAnim?.dispose();
}
});
_moveAnim
?..reset()
..start();
_zoomAnim
?..reset()
..start();
} else {
_move(center, zoom);
}
}