Flutter Web中location.hasPermission()抛出TypeError问题求助
Flutter Web平台location包hasPermission()方法抛出类型错误
location包的相关方法在iOS和Android平台运行正常,但在Web平台调用location.hasPermission()时,包内部抛出类型错误。
我的代码:
_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; } }
错误信息:
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
使用的包及版本:
- location: 6.0.2
- flutter: 3.22.2
- dart: 3.4.3
请问有没有人成功在Web平台实现该功能?
内容的提问来源于stack exchange,提问作者Aaron Kennedy
相关产品推荐
相关产品推荐

