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

583 views Asked by At

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) {...}`
3

There are 3 answers

0
Kantine On BEST ANSWER

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/

1
Ozan Taskiran On

You need to rerun your application, if you add a package which adds native features.

Close your app (not hot reload/ hot restart) completely and rerun it.

0
Samier Shovo On

flutter clean

flutter pub get

run those commands and rerun your application