【发布时间】:2019-12-25 03:54:03
【问题描述】:
我正在尝试从displayPrediction() 获取位置值/名称并将其显示在我的文本表单字段中
这是来自 TextFormField 的调用
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'From'),
onTap: () async {
Prediction p = await PlacesAutocomplete.show( context: context, apiKey: kGoogleApiKey);
displayPrediction(p);
},
)
我想把这个地方保存回textformfield。
我的displayPrediction():
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);
print(address);
}
}
【问题讨论】:
-
getDetailsByPlaceId(p.placeId)的返回类型是什么,能发一下这个方法的代码吗??
-
我从这里开始关注:stackoverflow.com/a/55877236/11545939我是第一次使用 API。
标签: android google-maps flutter dart google-places-api