The Flutter map recenter button not working
dependency version = google_maps_flutter: ^2.1.6
Implement code
Future<void> _goToTheLake() async {
LatLng lat = LatLng(ctrl.getLat().value, ctrl.getLang().value);
print(lat);
final GoogleMapController controller = await _controller.future;
controller.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(target: lat, zoom: 15.0)));
setState(() {});
}
E/flutter (15144): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method camera#animate on channel plugins.flutter.io/google_maps_0)
E/flutter (15144): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (15144): <asynchronous suspension>

if anyone has a solution please drop a comment.
///map controller
Completer<GoogleMapController> mapController = Completer();
///create map controller
void onMapCreated(GoogleMapController controller) {
if(!mapController.isCompleted){
mapController.complete(controller);
}
}
@override
void dispose() {
mapController = Completer();
super.dispose();
}
here's works fine for me
Hope this helps
Completer<GoogleMapController> _controller = Completer();
if(!freezeMap) {
_controller.future.then((value) =>
value.animateCamera(
CameraUpdate.newLatLngZoom(
LatLng(loc.lat, loc.long), zoomLevel)));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With