|
|
|
|
@ -46,22 +46,59 @@ class LocationUtilities {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) {
|
|
|
|
|
void done(Position position) {
|
|
|
|
|
//AppStorage.sp.saveLocation(position);
|
|
|
|
|
Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
|
|
|
|
|
bool isMocked = position.isMocked;
|
|
|
|
|
callback(position, isMocked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
locationFun((granted) {
|
|
|
|
|
if (granted) {
|
|
|
|
|
Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) {
|
|
|
|
|
done(value);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
errorCallBack();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// AppPermissions
|
|
|
|
|
}
|
|
|
|
|
}, context);
|
|
|
|
|
// return;
|
|
|
|
|
// Permission.location.isGranted.then((isGranted) {
|
|
|
|
|
// if (!isGranted) {
|
|
|
|
|
// Permission.location.request().then((granted) {
|
|
|
|
|
// print("granted:$granted");
|
|
|
|
|
// if (granted == PermissionStatus.granted) {
|
|
|
|
|
// Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
|
|
|
|
|
// bool isMocked = position.isMocked;
|
|
|
|
|
// callback(position, isMocked);
|
|
|
|
|
// }).catchError((err) {
|
|
|
|
|
// print("getCurrentPositionError:$err");
|
|
|
|
|
// errorCallBack();
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// errorCallBack();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
|
|
|
|
|
// bool isMocked = position.isMocked;
|
|
|
|
|
// callback(position, isMocked);
|
|
|
|
|
// }).catchError((err) {
|
|
|
|
|
// print("getCurrentPositionError:$err");
|
|
|
|
|
// errorCallBack();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
|
|
|
|
|
// // bool isMocked = position.isMocked;
|
|
|
|
|
// // callback(position, isMocked);
|
|
|
|
|
// // }).catchError((err) {
|
|
|
|
|
// // print("getCurrentPositionError:$err");
|
|
|
|
|
// // errorCallBack();
|
|
|
|
|
// // });
|
|
|
|
|
//
|
|
|
|
|
// // locationFun((granted) {
|
|
|
|
|
// // if (granted) {
|
|
|
|
|
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) {
|
|
|
|
|
// // done(value);
|
|
|
|
|
// // }).catchError((err) {
|
|
|
|
|
// // print("getCurrentPositionError:$err");
|
|
|
|
|
// // errorCallBack();
|
|
|
|
|
// // });
|
|
|
|
|
// // } else {
|
|
|
|
|
// // // AppPermissions
|
|
|
|
|
// // }
|
|
|
|
|
// // }, context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|