[英]flutter_google_places just loading & not show the result
I try using flutter_google_places: ^0.3.0 to autocomplete google search location, but the output just only loading not showing the location result.我尝试使用 flutter_google_places: ^0.3.0 来自动完成谷歌搜索位置,但 output 只是加载而不显示位置结果。
here my code,这是我的代码,
maps-example.dart地图示例.dart
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart' as Loc;
import 'package:geocoding/geocoding.dart';
import 'package:flutter_google_places/flutter_google_places.dart';
import 'package:google_maps_webservice/places.dart';
const kGoogleApiKey = "YourAPIKEY";
GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: kGoogleApiKey);
class MapScreen extends StatefulWidget {
static const String routeName = '/maps';
const MapScreen({Key? key}) : super(key: key);
@override
_MapScreenState createState() => _MapScreenState();
}
class _MapScreenState extends State<MapScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
RaisedButton(
onPressed: () async {
Prediction? p = await PlacesAutocomplete.show(
context: context,
apiKey: kGoogleApiKey,
mode: Mode.overlay,
radius: 10000000,
types: [],
strictbounds: false,
decoration: InputDecoration(
hintText: 'Search Location',
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
),
);
},
)
],
),
);
}
}
i already check my api key was not restrict but still happen like this.我已经检查过我的 api 密钥没有受到限制,但仍然这样发生。
here my output这是我的 output
thanks for your reply:)感谢您的回复:)
if your billing its activate on Google APIS try adding components如果您的账单在 Google APIS 上激活,请尝试添加组件
Prediction? p =
await PlacesAutocomplete.show(
context: context,
radius: 10000000,
types: [],
logo: const SizedBox.shrink(),
strictbounds: false,
mode: Mode.overlay,
language: "fr",
components: [ //add this
Component(
Component.country, "fr"),
Component(
Component.country, "in"),
Component(Component.country, "UK")
],
apiKey: kGoogleApiKey);
I had the same issue, and as hinted a little bit in @Ashutosh singh's comment, it was my billing account being closed.我遇到了同样的问题,正如@Ashutosh singh 的评论中所暗示的那样,这是我的账单账户被关闭了。 I'm not sure why it closed, but I just browsed to the Google API console, found the project, selected the Billing Account and 'Reopen' the search then returned results immediately.
我不确定它为什么关闭,但我只是浏览到 Google API 控制台,找到该项目,选择结算帐户并“重新打开”搜索,然后立即返回结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.