Home > Enterprise >  geocoding Flutter, can't import 'package:geocoding/geocoding.dart'
geocoding Flutter, can't import 'package:geocoding/geocoding.dart'

Time:10-15

I'm using geolocator: ^7.7.0 to get longitude and latitude coordinates so that way I can get the adress with placemarkFromCoordinates().

Everything is going well:

Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print('Latitude: ${position.latitude}, Longitude: ${position.longitude}');

As you can see I'm able to get longitude and latitude coordinates. The problem is that when I try to import 'package:geocoding/geocoding.dart' to use placemarkFromCoordinates() the following error occurs:

Target of URI doesn't exist: 'package:geocoding/geocoding.dart'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist. (darturi_does_not_exist)

I already tried to flutter clean and fluter build apk and the following come:

Note: C:\REMSYSTEMFIRE-FIXOS\Componentes\flutter\.pub-cache\hosted\pub.dartlang.org\geocoding-2.0.1\android\src\main\java\com\baseflow\geocoding\Geding\GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

My pubspec.yaml dependencies has both:

geolocator: ^7.7.0
geocoding: ^2.0.1

My AndroidManifest.xml permissions:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

build.gradle:

compileSdkVersion 31
minSdkVersion 21
targetSdkVersion 30

gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

And all others android. dependencies was replaced to their AndroidX counterparts.

Please, is that someone that know the reason of that problem?

Thank's.

CodePudding user response:

Make sure you declare the geolocator: ^7.7.0, geocoding: ^2.0.1 correctly. and run flutter packages get

Also Few Extra steps :

  1. Flutter Clean
  2. Close Android Studio or Vs Code
  3. Remove Build Folder
  4. Remove .idea Folder
  5. Finger Crossed!
  • Related