|
|
|
|
@ -28,7 +28,7 @@ class LocationUtils {
|
|
|
|
|
|
|
|
|
|
LocationUtils({@required this.isShowConfirmDialog, @required this.context, this.isHuawei = false});
|
|
|
|
|
|
|
|
|
|
void getCurrentLocation({Function(LatLng) callBack}) async {
|
|
|
|
|
void getCurrentLocation({Function(LatLng) callBack, Function() failureCallBack}) async {
|
|
|
|
|
if (Platform.isAndroid && isHuawei) {
|
|
|
|
|
_getHMSCurrentLocation(callBack);
|
|
|
|
|
} else {
|
|
|
|
|
@ -68,7 +68,7 @@ class LocationUtils {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (isShowConfirmDialog) showErrorLocationDialog(false);
|
|
|
|
|
if (isShowConfirmDialog) showErrorLocationDialog(false, failureCallBack: failureCallBack);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
@ -141,14 +141,28 @@ class LocationUtils {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showErrorLocationDialog(bool isPermissionError) {
|
|
|
|
|
showErrorLocationDialog(bool isPermissionError, {Function() failureCallBack}) {
|
|
|
|
|
ConfirmDialog dialog = new ConfirmDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
confirmMessage: TranslationBase.of(context).locationDialogMessage,
|
|
|
|
|
okText: TranslationBase.of(context).confirm,
|
|
|
|
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
|
|
|
|
okFunction: () => {ConfirmDialog.closeAlertDialog(context), if (isPermissionError) Geolocator.openAppSettings() else Geolocator.openLocationSettings(), Navigator.of(context).canPop()},
|
|
|
|
|
cancelFunction: () => {});
|
|
|
|
|
okFunction: () {
|
|
|
|
|
ConfirmDialog.closeAlertDialog(context);
|
|
|
|
|
if (isPermissionError)
|
|
|
|
|
Geolocator.openAppSettings();
|
|
|
|
|
else
|
|
|
|
|
Geolocator.openLocationSettings();
|
|
|
|
|
Navigator.of(context).canPop();
|
|
|
|
|
if (failureCallBack != null) {
|
|
|
|
|
failureCallBack();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
cancelFunction: () {
|
|
|
|
|
if (failureCallBack != null) {
|
|
|
|
|
failureCallBack();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return dialog.showAlertDialog(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|