flutter - 使用 flutter_google_places 自动完成搜索不起作用?
问题描述
我正在开发我的第一个更复杂的项目,类似于 Uber 应用程序的想法。
我按照这个问题中的说明使用颤振自动完成
但是当我尝试搜索地址时,什么也没有出现
我正在使用 GetX 进行状态管理
这是我的代码,在视图中:
child: TextField(
onTap: () async {
Prediction p = await PlacesAutocomplete.show(
context: Get.context,
apiKey: "my_apikey_is_here",
language: "pt",
components: [Component(Component.country, "br")],
mode: Mode.overlay);
controller.displayPrediction(p);
},
controller: _controllerDestino,
decoration: InputDecoration(
icon: Container(
margin: EdgeInsets.only(left: 10),
child: Icon(
Icons.local_taxi,
color: Colors.black,
),
),
hintText: "Digite o destino",
border: InputBorder.none),
)
控制器中的方法和语句:
static const kGoogleApiKey = "my_ApiKey_isHere";
GoogleMapsPlaces places = GoogleMapsPlaces(apiKey: kGoogleApiKey);
Future<Null> displayPrediction(Prediction p) async {
if (p != null) {
PlacesDetailsResponse detail =
await places.getDetailsByPlaceId(p.placeId);
var placeId = p.placeId;
double lat = detail.result.geometry.location.lat;
double lng = detail.result.geometry.location.lng;
var address = await Geocoder.local.findAddressesFromQuery(p.description);
print(lat);
print(lng);
update();
}
}
在 Google Cloud Platform 上,我对 Api Places 的请求 100% 都会导致错误,如下图所示
我看到一些论坛说我有义务将项目与计费帐户相关联,我做到了,但问题仍然存在
如果有人可以帮助我,请提前谢谢
解决方案
推荐阅读
- unity3d - unity获取半径2D中的所有元素
- azure - Azure 数据工厂 - 将文件列表复制到平面目录并保留文件名
- javascript - 如何在express js中加载根文件后向响应方法添加超时功能
- arrays - 如何将键值对从字典映射到数组
- python - Python N 嵌套循环
- javascript - 当我调整浏览器大小时,页脚 div 与上面的 div 重叠。我做错了什么?
- java - 有没有办法在 Spring Boot 中禁用 InfluxDB?
- javascript - 在 JavaScript 中查找 2 个标记之间花费的时间
- wso2 - 使用 siddhi 在某个时间窗口内未发生事件时发送警报
- python - 赛车模拟器的 Numpy 问题:没有名为“numpy.core._multiarray_umath”的模块