flutter2.0使用获取位置(AmapLocation.instance.fetchLocation)时出现类型错误: _TypeError (type '(CLLocationCoordinate2D?) => Future<double?>?' is not a subtype of type '(CLLocationCoordinate2D?) => Future<double?>')
libaoxu opened this issue · comments
李宝旭 commented
插件版本 0.21.0-dev.0
遇到bug的平台(Android/iOS) ios
描述bug
使用API: await AmapLocation.instance.fetchLocation();
获取位置时, 报错: _TypeError (type '(CLLocationCoordinate2D?) => Future<double?>?' is not a subtype of type '(CLLocationCoordinate2D?) => Future<double?>')
复现步骤 稳定复现
期望行为 获取成功
flutter doctor 正常
修改方式
在lib/src/facade/amap_location.dart
中156行改为使用Future<double?>?
来声明变量
old
final latitude =
await location!.coordinate.then((it) => it?.latitude);
final longitude =
await location.coordinate.then((it) => it?.longitude);
new
Future<double?>? latitude =
await location!.coordinate.then((it) => it?.latitude);
Future<double?>? longitude =
await location.coordinate.then((it) => it?.longitude);
更改前后如图
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.