@ -36,9 +36,12 @@ class LocationUtils {
if ( value ) {
await Geolocator . checkPermission ( ) . then ( ( permission ) async {
if ( permission = = LocationPermission . always | | permission = = LocationPermission . whileInUse ) {
Geolocator . getCurrentPosition ( desiredAccuracy: LocationAccuracy . low , timeLimit: Duration ( seconds: 1 0 ) ) . then ( ( value ) {
Geolocator . getCurrentPosition ( desiredAccuracy: LocationAccuracy . best , timeLimit: Duration ( seconds: 1 ) ) . then ( ( value ) {
setLocation ( value ) ;
if ( callBack ! = null ) callBack ( LatLng ( value . latitude , value . longitude ) ) ;
} ) . catchError ( ( err ) {
print ( err ) ;
if ( isShowConfirmDialog ) showLocationTimeOutDialog ( failureCallBack: failureCallBack ) ;
} ) ;
}
@ -52,7 +55,7 @@ class LocationUtils {
if ( callBack ! = null ) callBack ( LatLng ( value . latitude , value . longitude ) ) ;
} ) ;
} else {
if ( isShowConfirmDialog ) showErrorLocationDialog ( false );
if ( isShowConfirmDialog ) showErrorLocationDialog ( false , failureCallBack: failureCallBack );
}
} ) ;
} else {
@ -60,7 +63,7 @@ class LocationUtils {
getCurrentLocation ( callBack: callBack ) ;
} else {
setZeroLocation ( ) ;
if ( isShowConfirmDialog ) showErrorLocationDialog ( false );
if ( isShowConfirmDialog ) showErrorLocationDialog ( false , failureCallBack: failureCallBack );
}
}
}
@ -141,6 +144,27 @@ class LocationUtils {
}
}
showLocationTimeOutDialog ( { Function ( ) failureCallBack } ) {
ConfirmDialog dialog = new ConfirmDialog (
context: context ,
confirmMessage: TranslationBase . of ( context ) . locationTimeoutError ,
okText: TranslationBase . of ( context ) . ok ,
cancelText: TranslationBase . of ( context ) . cancel_nocaps ,
okFunction: ( ) {
ConfirmDialog . closeAlertDialog ( context ) ;
Navigator . of ( context ) . canPop ( ) ;
if ( failureCallBack ! = null ) {
failureCallBack ( ) ;
}
} ,
cancelFunction: ( ) {
if ( failureCallBack ! = null ) {
failureCallBack ( ) ;
}
} ) ;
return dialog . showAlertDialog ( context ) ;
}
showErrorLocationDialog ( bool isPermissionError , { Function ( ) failureCallBack } ) {
ConfirmDialog dialog = new ConfirmDialog (
context: context ,