首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >LatLng(double.parse(prediction.lat),double.parse(prediction.long))参数类型'String?‘不能分配给参数类型'String‘

LatLng(double.parse(prediction.lat),double.parse(prediction.long))参数类型'String?‘不能分配给参数类型'String‘
EN

Stack Overflow用户
提问于 2021-12-07 07:20:46
回答 1查看 31关注 0票数 0

如何解决颤振项目中的这个错误?

代码语言:javascript
运行
复制
     Future<void> getLocationFromPlace(int index) async {
    if (autocompletePlaces.isNotEmpty) {
      locationController.text = autocompletePlaces[index].description!;
      searchAddressController.clear();
      final prediction =
          await _service.getPlaceDetail(autocompletePlaces[index], uuid);
      uuid = const Uuid().v4();
      updatePosition(
          LatLng(double.parse(prediction.lat), double.parse(prediction.long)));
      autocompletePlaces.clear();
    }
  }
EN

回答 1

Stack Overflow用户

发布于 2021-12-07 08:13:40

这个问题是通过在没有空检查的情况下将String?变量传递到String参数引起的。

要绕过错误,可以执行以下操作:autocompletePlaces[index].description ?? ''使变量成为String

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70256252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档