I have existing project which using geolocator, for getting location. geolocator: ^9.0.2
Map mreturn;
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
Location location = new Location();
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
mreturn = {"status": 0, "message": 'Location Denied once'};
return mreturn;
}
}
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
mreturn = {"status": 0, "message": 'Location permissions are denied'};
return mreturn;
// return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
mreturn = {
"status": 0,
"message":
'Location permissions are permanently denied, we cannot request permissions.'
};
return mreturn;
// return Future.error(
// 'Location permissions are permanently denied, we cannot request permissions.');
}
Position position = await Geolocator.getCurrentPosition();
mreturn = {"status": 1, "message": "Location Received", "position": position};
return mreturn;
Its working fine. Now I implemented easy_geofencing for geofencing and geolocator for getting location. easy_geofencing: ^0.2.0 Its giving errors:
/Users/lasthoney/.pub-cache/hosted/pub.dartlang.org/geolocator_android-2.1.0/android/src/main/java/com/baseflow/geolocator/permission/PermissionUtils.java:27: warning: [deprecation] getPackageInfo(String,int) in PackageManager has been deprecated
.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
^
error: warnings found and -Werror specified
1 error
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':geolocator_android:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Error due to geolocator_android package. easy_geofencing using old version of geolocator_android.
I shift to geofence_flutter.