I am implementing getting device location for Huawei devices, it is working when permission is granted but when is denied app is crashing.
With location from google it never happened.
Here is my code for getting location:
Future<Location?> getAccuratePositionH() async {
PermissionHandler permissionHandler = PermissionHandler();
bool status = await permissionHandler.requestLocationPermission();
if (status) {
FusedLocationProviderClient locationService = FusedLocationProviderClient();
Location location = await locationService.getLastLocation();
return location;
}
else {
return null;
}
}
This is what I am getting in console:
I/cgr.qrmv.QrMobVisPlugin( 5178): Permissions request denied.
W/cgr.qrmv.QrMobVisPlugin( 5178): Starting QR Mobile Vision failed
W/cgr.qrmv.QrMobVisPlugin( 5178): com.github.rmtmckenzie.qrmobilevision.QrReader$Exception: QR reader failed because noPermissions
and
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.lea24.partyfinder/com.lea24.partyfinder.MainActivity}: java.lang.NullPointerException: Attempt to read from field 'io.flutter.plugin.common.MethodChannel$Result com.github.rmtmckenzie.qrmobilevision.QrMobileVisionPlugin$ReadingInstance.startResult' on a null object reference
Why is here QR Mobile Vision? I don't know, really, it's happening after denied location permissions.
What am I doing wrong and how to fix it?