问题描述
我正在开发我的第一个更复杂的项目,类似于优步应用的想法。
我按照此问题中的说明进行操作 autocomplete with flutter
但是当我尝试搜索地址时,什么也没有出现
我使用 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 上,我 100% 的 Api Places 请求都会导致错误,如下图所示
我看到一些论坛说我必须将项目与结算帐户链接,我做到了,但问题仍然存在
如果有人可以帮助我,在此先感谢您