flutter_google_places 只是加载而不显示结果
flutter_google_places just loading & not show the result
我尝试使用 flutter_google_places: ^0.3.0 来自动完成 google 搜索位置,但输出只是加载而不显示位置结果。
这是我的代码,
地图-example.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,
),
),
),
);
},
)
],
),
);
}
}
我已经检查过我的 api 密钥没有被限制,但仍然这样。
这是我的输出
感谢您的回复:)
如果您的帐单在 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);
我尝试使用 flutter_google_places: ^0.3.0 来自动完成 google 搜索位置,但输出只是加载而不显示位置结果。
这是我的代码,
地图-example.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,
),
),
),
);
},
)
],
),
);
}
}
我已经检查过我的 api 密钥没有被限制,但仍然这样。
这是我的输出
感谢您的回复:)
如果您的帐单在 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);