Search code examples
flutterdartgeocodingreverse-geocoding

Error: MissingPluginException(No implementation found for method locationFromAddress on channel flutter.baseflow.com/geocoding)


I want to convert some address to coordinates but I am getting this MissingPluginException error and it is caused by my locationFromAddress call and it prevents the navigator to function. The code worked properly before I added locationFromAddress. What can this error mean and how do I fix this? Error: MissingPluginException(No implementation found for method locationFromAddress on channel flutter.baseflow.com/geocoding)

my code

`import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:geolocator/geolocator.dart';
import 'package:geocoding/geocoding.dart';

@OverRide
void didChangeDependencies() {
super.didChangeDependencies();
SchedulerBinding.instance.addPostFrameCallback((_) async {
userPosition = await getUserPosition();
locs = await GeocodingPlatform.instance.locationFromAddress('my address');
loc = locs.first;
if (context.mounted) {
Navigator.pushReplacementNamed(context, 'map', arguments: {
'userPosition': userPosition,
'loc': loc,
});
}
});
}

Position? userPosition;
Location? loc;
List locs = [];

@OverRide
Widget build(BuildContext context) {...}`

Solution

  • This package can be used only with Android and IOS according to the pub page: https://pub.dev/packages/geocoding

    It means that no implementation is done for the other platforms (Web, Windows, MacOS, Linux), which leads to a MissingPluginException error if you try to use the package with another platform than Android or IOS. If you really want to use geolocation with another platform, try another package. You can find some of them with the platforms they work on here: https://fluttergems.dev/geolocation-utilities/