gpt4 book ai didi

flutter - 未处理的异常 : Bad state: Cannot add new events after calling close, 使用 flttter_google_places

转载 作者:行者123 更新时间:2023-12-03 02:55:10 30 4
gpt4 key购买 nike

每次使用 PlacesAutoComplete 小部件时,我都会收到此错误。搜索/请求/响应一切正常,没有崩溃或任何事情。但是日志在每次搜索时都会向我显示此错误。

我为它添加了两个包:flutter_google_places 和 google_web_services。

而且我根本不使用流。所以这对我来说是一个非常奇怪的错误。

我为此遵循了几个在线指南,谁能解释我做错了什么?

另外,我看到这是实现地点自动完成的一种非常基本的方法。我希望您提供有关实现 Google 地点搜索的更好方法的建议。

Here is the error i get

Future<void> _searchWithPlacesAutoComplete() async {
Prediction _predictions = await PlacesAutocomplete.show(
context: context,
apiKey: GOOGLE_API_KEY,
onError: (response) => _showError(response),
mode: Mode.overlay,
language: "en",
components: [Component(Component.country, "uk")],
location: _currentLocation,
radius: 50,
);

if (_predictions != null) {
PlacesDetailsResponse detail =
await GoogleMapsPlaces(apiKey: GOOGLE_API_KEY)
.getDetailsByPlaceId(_predictions.placeId);
final lat = detail.result.geometry.location.lat;
final lng = detail.result.geometry.location.lng;

setState(() {
_markedPosition = new LatLng(lat, lng);
});
mapController.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: _markedPosition,
zoom: 16.0,
),
),
);
}
}

最佳答案

这是他们在 git 代码中修复的插件错误。不幸的是,它尚未在当前版本中更新。

您可以做的是将所有 src 文件集成到他们的 github lib 文件夹中。它为我解决了这个问题。

具体步骤:

[1] 转至 https://github.com/fluttercommunity/flutter_google_places/tree/master/lib/src
[2] 将所有dart文件复制到我的项目中

关于flutter - 未处理的异常 : Bad state: Cannot add new events after calling close, 使用 flttter_google_places,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61881150/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com