根据文档,此方法似乎在 iOS 和 Android 上完美运行,但在 Web 上,我在包中遇到随机类型错误。
这是我的代码:
_serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
_serviceEnabled = await location.requestService();
if (!_serviceEnabled) {
StackTrace.current
.printWithInfo('No User Location Available: Services Not Enabled!');
streamController.add(_initialFocusLocation);
return;
}
}
// try {
_permissionGranted = await location.hasPermission();
if (_permissionGranted == PermissionStatus.denied ||
_permissionGranted == PermissionStatus.deniedForever) {
_permissionGranted = await location.requestPermission();
if (_permissionGranted != PermissionStatus.granted ||
_permissionGranted != PermissionStatus.grantedLimited) {
StackTrace.current
.printWithInfo('No User Location Available: Permission Not Granted!');
streamController.add(_initialFocusLocation);
return;
}
}
错误在location.hasPermission()处抛出
TypeError: Failed to execute 'query' on 'Permissions': Failed to read the 'name' property from 'PermissionDescriptor': Required member is undefined.
packages/location_web/location_web.dart 60:15 hasPermission
有人可以在网络上使用此功能吗?
软件包和版本: 位置:6.0.2 颤动:3.22.2 飞镖:3.4.3
而不是使用: _permissionGranted = wait location.hasPermission(); 使用:_permissionGranted =等待location.requestPermission();
网页版