Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 谷歌在搜索时不显示地址_Flutter_Dart_Google Places Api - Fatal编程技术网

Flutter 谷歌在搜索时不显示地址

Flutter 谷歌在搜索时不显示地址,flutter,dart,google-places-api,Flutter,Dart,Google Places Api,我目前正在开发一个应用程序,它使用google places autocomplete查找世界各地的地址。我已通过以下方式实施: Position currentPosition; var placeId, address; double lat, lng; getCurrentLocation(){ final Geolocator geolocator = Geolocator()..forceAndroidLocationManager; geolocator

我目前正在开发一个应用程序,它使用google places autocomplete查找世界各地的地址。我已通过以下方式实施:

Position currentPosition;
var placeId, address;
double lat, lng;

 getCurrentLocation(){
    final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
    geolocator
      .getCurrentPosition(desiredAccuracy: LocationAccuracy.best)
      .then((Position position){
        setState(() {
          currentPosition = position;
        });
      }).catchError((e){
        print(e);
      });
  }

Future<Null> displayPrediction(Prediction p) async {
    if (p != null) {
      PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p.placeId);
      placeId = p.placeId;
      lat = detail.result.geometry.location.lat;
      lng = detail.result.geometry.location.lng;
      address = await Geocoder.local.findAddressesFromQuery(p.description);
    }
  }

onPressed: () async {
  print(currentPosition.latitude);
  print(currentPosition.longitude);
  Prediction prediction = await PlacesAutocomplete.show(
    context: context, 
    apiKey: googleApiKey,
    location: Location(currentPosition.latitude, currentPosition.longitude),
    radius: 100000000,
    mode: Mode.overlay,
    language: "en",
  );

位置当前位置;
变量placeId,地址;
双lat,液化天然气;
getCurrentLocation(){
最终地理定位器Geolocator=Geolocator()…forceAndroidLocationManager;
地理定位器
.getCurrentPosition(所需精度:定位精度。最佳)
.然后((位置){
设置状态(){
当前位置=位置;
});
}).catchError((e){
印刷品(e);
});
}
未来显示预测(预测p)异步{
如果(p!=null){
PlacesDetailsResponse detail=等待_places.getDetailsByPlaceId(p.placeId);
placeId=p.placeId;
lat=detail.result.geometry.location.lat;
lng=详图.result.geometry.location.lng;
地址=wait Geocoder.local.findAddressesFromQuery(p.description);
}
}
onPressed:()异步{
打印(当前位置、纬度);
打印(当前位置、经度);
预测预测=等待地点sautoComplete.show(
上下文:上下文,
阿皮奇,
位置:位置(currentPosition.latitude,currentPosition.latitude),
半径:100000000,
mode:mode.overlay,
语言:“恩”,
);
但是,每当我在搜索栏中键入内容时,我都不会收到任何自动完成的结果,我也不知道为什么(附图片)。如果有什么不同,我使用的是iOS模拟器。我还没有在Android上进行测试。任何帮助都将不胜感激


希望这能有所帮助:事实上,这是我用来启发灵感的代码。但是,它似乎对我不起作用。我做了一些研究,发现人们说它不起作用,因为他们没有启用计费。这可能是我的问题吗?可能是访问api被拒绝。请检查api是否已启用。请参阅仅供参考:我相信我的api已启用。但我没有链接计费帐户链接计费帐户是强制性的。请按照谷歌的入门指南正确设置项目和计费帐户,希望这有帮助:这实际上是我用来启发灵感的代码。然而,它似乎对我不起作用。我做了一些工作研究发现,人们说它不起作用,因为他们没有启用计费。这可能是我的问题吗?可能是api访问被拒绝。请检查api是否已启用。请参阅此参考:我相信我的api已启用。但我没有链接计费帐户链接计费帐户是强制性的。请按照Google的入门指南在以下位置正确设置项目和账单帐户: