fluttify-project / amap_location_fluttify

高德地图 定位组件 Flutter插件

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flutter2.0使用获取位置(AmapLocation.instance.fetchLocation)时出现类型错误: _TypeError (type '(CLLocationCoordinate2D?) => Future<double?>?' is not a subtype of type '(CLLocationCoordinate2D?) => Future<double?>')

libaoxu opened this issue · comments

插件版本 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?>')

复现步骤 稳定复现

期望行为 获取成功

截图
image

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);

更改前后如图

old:
image

new:
image

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.