Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

here my code,

maps-example.dart

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

enter image description here

thanks for your reply 🙂

>Solution :

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);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading