Android _TypeError(类型“List”不是类型“PlaceDetails”的子类型)

Android _TypeError(类型“List”不是类型“PlaceDetails”的子类型),android,google-maps,flutter,dart,google-places-api,Android,Google Maps,Flutter,Dart,Google Places Api,请帮助我解决此错误: 我正在尝试从displayPrediction获取位置值/名称,并将其显示在我的textformfield中 这是来自TextFormField的呼叫 TextFormField( decoration: textInputDecoration.copyWith(hintText: 'From'), onTap: () async { Prediction p = await PlacesAutocomplete.show( context: context,

请帮助我解决此错误:

我正在尝试从displayPrediction获取位置值/名称,并将其显示在我的textformfield中 这是来自TextFormField的呼叫

TextFormField(
 decoration: textInputDecoration.copyWith(hintText: 'From'),
  onTap: () async {
   Prediction p = await PlacesAutocomplete.show( context: context, apiKey: kGoogleApiKey);
   displayPrediction(p);
  },
)
我想把这个地方保存回textformfield。 我的预测:


只需签出您的google places导入依赖项。应该是这样

import 'package:flutter_google_places/flutter_google_places.dart';
此外,您已将_位置初始化为

GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: "YOUR_API_KEY");

错误与p描述一致。我也面临同样的问题。 像这样使用它:

List address = [];
  address.add(p.description);

  print(address);

getDetailsByPlaceIdp.placeId的返回类型是什么,你能发布这个方法的代码吗?我从这里开始:我是第一次使用API.import“包:flatter_google_places/flatter_google_places.dart”;导入“包:geocoder/geocoder.dart”;导入“包:google_maps_webservice/places.dart”;const kGoogleApiKey=MY_API_KEY;GoogleMapsPlaces _places=GoogleMapsPlacesapiKey:kGoogleApiKey;我认为你应该删除这个导入包:geocoder/geocoder.dart;导入“包:google_maps_webservice/places.dart”;然后检查您使用的GoogleMapsPlaces是否来自正确的软件包。就像使用多个依赖项一样,可能所有不同的依赖项都有一个名称相同的类,比如GoogleMapsPlaces。
List address = [];
  address.add(p.description);

  print(address);