-
-
Notifications
You must be signed in to change notification settings - Fork 829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web hasPermission() throwing TypeError for standard use #987
Comments
Interested as well if anyone has this working on web. |
I faced the same error with the web. Has anyone fixed it? |
After some investigation it seems that the problem comes from the permission_handler_html plugin used in flutter Web. a permission_handler_html update fixes the problem version 0.1.3+1 Since a new update removes "PermissionDescripttor" from flutter Web and permission_handler_html (change log). The temporary solution at this stage is to use the following overrides;
In pubspec.yaml waiting for a plugin update. |
Thanks for the investigation. Unfortunately the temporary solution doesn't seem to work when there are other packages that also rely on web. I set the overrides as you specified Im using the following package versions: And get the following error: `Launching lib/main.dart on Chrome in debug mode... Exited (1). I'd prefer not to have to revert all the above packages to versions that are compatible with web: 0.5.1... Any other ideas/solutions? Or am I misinterpreting the error? Thanks! |
Workaround i use import 'package:location/location.dart' as location;
import 'package:universal_html/html.dart' as html;
final locationService = location.Location();
PermissionStatus permissionStatus = kIsWeb ? await _checkLocationPermissionOnWeb() : await locationService.hasPermission();
Future<PermissionStatus> _checkLocationPermissionOnWeb() async {
html.PermissionStatus? _status = await html.window.navigator.permissions?.query({'name': 'geolocation'});
switch (_status?.state) {
case 'granted':
return PermissionStatus.granted;
case 'prompt':
return PermissionStatus.denied;
case 'denied':
default:
return PermissionStatus.deniedForever;
}
} |
Describe the bug
This method per the documentation seems to work perfectly on iOS and Android but on Web I'm getting a random type error within the package.
Here's my code:
The error is thrown at location.hasPermission() and serviceEnabled returns true.
Does anyone have this working on the web?
Tested on:
Packages and versions:
location: 6.0.2
flutter: 3.22.2
dart: 3.4.3
Expected Behavior:
On iOS and Android, this code works fine regardless of permission level. I would expect it to return some enum value instead of throwing a TypeError. Even if the location is not supported on the web at all, I would expect some level of a named error with instructions on some resolution or advising not to use this package and method for this platform.
The text was updated successfully, but these errors were encountered: