_TypeError(类型"List< dynamic>"不是类型"PlaceDetails"的子类型) [英] _TypeError (type 'List<dynamic>' is not a subtype of type 'PlaceDetails')
本文介绍了_TypeError(类型"List< dynamic>"不是类型"PlaceDetails"的子类型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我解决此错误:
Help me with this error:
我正在尝试从displayPrediction()
获取位置值/名称并将其显示在我的textformfield中
这是来自TextFormField的电话
I am trying to get place value/name from displayPrediction()
and show it in my textformfield
Here is the call from TextFormField
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'From'),
onTap: () async {
Prediction p = await PlacesAutocomplete.show( context: context, apiKey: kGoogleApiKey);
displayPrediction(p);
},
)
我想将地点保存回textformfield.
我的displayPrediction()
:
I want to save the place back to textformfield.
My 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);
}
}
推荐答案
该错误与p.description有关.我遇到了同样的问题. 像这样使用它:
The error is with p.description. I faced the same issue. Use it like this :
List address = [];
address.add(p.description);
print(address);
这篇关于_TypeError(类型"List< dynamic>"不是类型"PlaceDetails"的子类型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文