MissingPluginException(No implementation found for method placemarkFromCoordinates on channel flutter.baseflow.com/geocoding) I want to access the current location of device and I am able to get it locally, but on flutter web and after deployment it gives me the exception above, how to handle this exception please.
Future<Position> _getCurrentLocation() async {
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location services are disabled.');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.best,
forceAndroidLocationManager: true)
.then((Position position) {
setState(() {
_currentPosition = position;
_getAddressFromLatLng();
});
}).catchError((e) {
if (kDebugMode) {
print(e);
}
});
return await Geolocator.getCurrentPosition();
}
Here I am converting the LAT LNG to Address.
_getAddressFromLatLng() async {
try {
List<Placemark> placemarks = await placemarkFromCoordinates(
_currentPosition!.latitude, _currentPosition!.longitude);
Placemark place = placemarks[0];
setState(() {
_currentAddress = "${place.locality}, ${place.country}";
});
} catch (e) {
if (kDebugMode) {
print(e);
}
}
}