每次使用PlacesAutoComplete小部件时,都会出现此错误。搜索/请求/响应一切正常,没有崩溃或任何故障。但是日志在每次搜索时都会向我显示此错误。
我为此添加了两个软件包:flutter_google_places和google_web_services。
我根本不使用流。所以这对我来说是一个非常奇怪的错误。
为此,我遵循了一些在线指南,有人可以解释我在做什么错吗?
此外,我看到这是实现场所自动完成的非常基本的方法。我希望您提出更好的方法来实施Google地方信息搜索。
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,
),
),
);
}
}
答案 0 :(得分:2)
这是一个插件错误,已在其git代码中修复。不幸的是,当前版本尚未对其进行更新。
您可以做的是将所有src文件集成到其github lib文件夹中。它为我解决了这个问题。
确切步骤:
[1]转到https://github.com/fluttercommunity/flutter_google_places/tree/master/lib/src [2]将所有dart文件复制到我的项目中
答案 1 :(得分:0)
StreamController<dynamic> subject = StreamController<dynamic>.broadcast();