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.
here my code,
maps-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,
),
),
),
);
},
)
],
),
);
}
}
i already check my api key was not restrict but still happen like this.
here my output
thanks for your reply :)
CodePudding user response:
if your billing its activate on Google APIS try adding components
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);