Google Places - Google places autocomplete widgets for flutter.

Overview

Flutter Community: flutter_google_places

flutter_google_places

pub version

Google places autocomplete widgets for flutter.

Getting Started

For help getting started with Flutter, view our online documentation.

# pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  flutter_google_places: 
   
const kGoogleApiKey = "API_KEY";

Prediction p = await PlacesAutocomplete.show(
                          context: context,
                          apiKey: kGoogleApiKey,
                          mode: Mode.overlay, // Mode.fullscreen
                          language: "fr",
                          components: [new Component(Component.country, "fr")]);

The library use google_maps_webservice library which directly refer to the official documentation for google maps web service.

Comments
  • Exception when closing Full screen PlacesAutocomplete view

    Exception when closing Full screen PlacesAutocomplete view

    Using the following code to open full-screen google place search view.

    Prediction place = await PlacesAutocomplete.show(
            context: context,
            hint: 'Enter City name',
            apiKey: 'xyz',
            mode: Mode.fullscreen,
            onError: (error) => {
                  print('Error in Place search = $error'),
                  if (error is PlacesAutocompleteResponse)
                    {print(error.errorMessage)}
                },
            language: 'en');
    

    But after exiting from full-screen view I am getting the following exception.

    [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: Cannot add new events after calling close
        #0      _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:251:24)
        #1      Subject._add (package:rxdart/src/subjects/subject.dart:141:17)
        #2      Subject.add (package:rxdart/src/subjects/subject.dart:135:5)
        #3      PlacesAutocompleteState._onQueryChange.<anonymous closure> (package:flutter_google_places/src/flutter_google_places.dart:418:22)
        #4      _rootRun (dart:async/zone.dart:1180:38)
        #5      _CustomZone.run (dart:async/zone.dart:1077:19)
        #6      _CustomZone.runGuarded (dart:async/zone.dart:979:7)
        #7      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
        #8      _rootRun (dart:async/zone.dart:1184:13)
        #9      _CustomZone.run (dart:async/zone.dart:1077:19)
        #10     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1003:23)
        #11     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
        #12     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
        #13     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
        #14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
    

    Please help me understand in case I am doing something wrong.

    opened by shubhambansal 16
  • flutter_google_places autocomplete shows search results once in while

    flutter_google_places autocomplete shows search results once in while

    My implemenatation TextField( decoration: InputDecoration( hintText: _hintPickUpPlace, border: InputBorder.none, icon: Icon(Icons.search,color: Colors.white,), hintStyle: TextStyle(fontSize: 18,color: Colors.white,fontWeight: FontWeight.bold) ), onTap: (){ showGooglePlaceWidget(); _state = States.pickUpSate; }, )

    Future showGooglePlaceWidget() async { Prediction p = await PlacesAutocomplete.show(

                context: context,
                apiKey: kGoogleApiKey,
                mode: Mode.overlay,
                language: "en",
                radius: _center == null ? null : 10000000
            );
    

    }

    opened by KNehe 13
  •  Exception: Null check operator used on a null value

    Exception: Null check operator used on a null value

    I'm not able to search any place don't know why, getting below issue

    [VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Null check operator used on a null value #0 PlacesAutocompleteState.doSearch (package:flutter_google_places/src/flutter_google_places.dart:436:28)

    opened by DineshTaral 12
  • Error on select place

    Error on select place

    _debounce time not closed on dispose

    void _onQueryChange() {
      if (_debounce?.isActive ?? false) _debounce.cancel();
      _debounce = Timer(Duration(milliseconds: widget.debounce), () {
        _queryBehavior.add(_queryTextController.text);
      });
    }
    

    Line of code!

    E/flutter ( 8027): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: Cannot add new events after calling close E/flutter ( 8027): #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:251:24) E/flutter ( 8027): #1 Subject._add (package:rxdart/src/subjects/subject.dart:141:17) E/flutter ( 8027): #2 Subject.add (package:rxdart/src/subjects/subject.dart:135:5) E/flutter ( 8027): #3 PlacesAutocompleteState._onQueryChange. (package:flutter_google_places/src/flutter_google_places.dart:418:22) E/flutter ( 8027): #4 _rootRun (dart:async/zone.dart:1180:38) E/flutter ( 8027): #5 _CustomZone.run (dart:async/zone.dart:1077:19) E/flutter ( 8027): #6 _CustomZone.runGuarded (dart:async/zone.dart:979:7) E/flutter ( 8027): #7 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1019:23) E/flutter ( 8027): #8 _rootRun (dart:async/zone.dart:1184:13) E/flutter ( 8027): #9 _CustomZone.run (dart:async/zone.dart:1077:19) E/flutter ( 8027): #10 _CustomZone.bindCallback. (dart:async/zone.dart:1003:23) E/flutter ( 8027): #11 Timer._createTimer. (dart:async-patch/timer_patch.dart:23:15) E/flutter ( 8027): #12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19) E/flutter ( 8027): #13 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5) E/flutter ( 8027): #14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

    opened by ErliSoares 10
  • version solving failed

    version solving failed

    Running "flutter pub get" in MobileApp...
    Because flutterapp depends on flutter_google_places ^0.3.0 which depends on rxdart ^0.26.0, rxdart ^0.26.0 is required. So, because flutterapp depends on rxdart ^0.27.3, version solving failed. pub get failed (1; So, because flutterapp depends on rxdart ^0.27.3, version solving failed.) exit code 1

    opened by NetFreaker 9
  • Types filter shows no results

    Types filter shows no results

    Hi, I'm working on an application, and in it, I need to display information of gyms (which is a supported type in the places api ([https://developers.google.com/places/supported_types]). If I do not enter a type into the constructor, then I get any type of place to show up without a problem. However, as soon as I add a list ie: list : ["gym"], no results appear. I have tried using "food" or other supported types, and no results appear. I am still relatively new to using flutter, so I may be misunderstanding how this widget works.

    The important snippet is below (taken from the example)

    class CustomSearchScaffold extends PlacesAutocompleteWidget {
      CustomSearchScaffold()
          : super(
              apiKey: constants.apiKey,
              sessionToken: Uuid().generateV4(),
              language: "en",
              hint: "Search for gym",
             // types: ["gym"]
            );
    
      @override
      _CustomSearchScaffoldState createState() => _CustomSearchScaffoldState();
    }
    ( rest of code to display autofill contents..)
    

    Any advice on how to fix this, or get around this bug would be greatly appreciated!

    opened by cedrichansen 8
  • Connection closed before full header was received, where should I try catch exactly?

    Connection closed before full header was received, where should I try catch exactly?

    E/flutter ( 5900): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Connection closed before full header was received
    E/flutter ( 5900): #0      IOClient.send (package:http/src/io_client.dart:62:7)
    E/flutter ( 5900): <asynchronous suspension>
    E/flutter ( 5900): #1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:91:38)
    E/flutter ( 5900): #2      BaseClient.get (package:http/src/base_client.dart:27:7)
    E/flutter ( 5900): #3      GoogleWebService.doGet (package:google_maps_webservice/src/utils.dart:53:52)
    E/flutter ( 5900): #4      GoogleMapsPlaces.autocomplete (package:google_maps_webservice/src/places.dart:164:46)
    E/flutter ( 5900): #5      PlacesAutocompleteState.doSearch (package:pickapp/utilities/pickapp_google_places.dart:428:33)
    E/flutter ( 5900): #6      _rootRunUnary (dart:async/zone.dart:1198:47)
    E/flutter ( 5900): #7      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
    E/flutter ( 5900): #8      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
    E/flutter ( 5900): #9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
    E/flutter ( 5900): #10     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
    E/flutter ( 5900): #11     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:385:25)
    E/flutter ( 5900): #12     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:250:5)
    E/flutter ( 5900): #13     _StartWithStreamSink.add (package:rxdart/src/transformers/start_with.dart:16:10)
    E/flutter ( 5900): #14     forwardStream.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:rxdart/src/utils/forwarding_stream.dart:34:49)
    E/flutter ( 5900): #15     forwardStream.runCatching (package:rxdart/src/utils/forwarding_stream.dart:24:12)
    E/flutter ( 5900): #16     forwardStream.<anonymous closure>.<anonymous closure> (package:rxdart/src/utils/forwarding_stream.dart:34:28)
    E/flutter ( 5900): #17     _rootRunUnary (dart:async/zone.dart:1198:47)
    E/flutter ( 5900): #18     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
    E/flutter ( 5900): #19     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
    E/flutter ( 5900): #20     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
    E/flutter ( 5900): #21     _DelayedData.perform (dart:async/stream_impl.dart:611:14)
    E/flutter ( 5900): #22     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
    E/flutter ( 5900): #23     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:687:7)
    E/flutter ( 5900): #24     _rootRun (dart:async/zone.dart:1182:47)
    E/flutter ( 5900): #25     _CustomZone.run (dart:async/zone.dart:1093:19)
    E/flutter ( 5900): #26     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
    E/flutter ( 5900): #27     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
    E/flutter ( 5900): #28     _rootRun (dart:async/zone.dart:1190:13)
    E/flutter ( 5900): #29     _CustomZone.run (dart:async/zone.dart:1093:19)
    E/flutter ( 5900): #30     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
    E/flutter ( 5900): #31     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
    E/flutter ( 5900): #32     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
    E/flutter ( 5900): #33     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
    

    it happens when I type any letter, and go back before getting any response

    #134

    Bug 
    opened by Hasankanso 7
  • Flutter Web - Can't google place autocomplete to work unless using proxy url.

    Flutter Web - Can't google place autocomplete to work unless using proxy url.

    Has anybody got the google place working without using the proxy url?

    Right now we are using 'cors-anywhere.herokuapp.com' as the proxy url and works with limitations, but in the long run we just do not want to use one.

    Is there something that I am not understanding about the web that requires a proxy url?

    opened by DavidHCox 6
  • Result don't show on my screen

    Result don't show on my screen

    I am having the following issue: I have a Flutter project with a Text Form Field where I am calling the flutter_google_places API. I can see the new screen when I click on it, the Powered By Google Logo, but when I search any address, I can't see any results, only a loading bar under the search bar, but no results, just a blank screen.

    This is the code I am using for now:

    TextFormField( decoration: textInputDecoration.copyWith( hintText: "Enter Company Address", prefixIcon: Icon(Icons.map), ), onTap: () async { Prediction p = await PlacesAutocomplete.show( context: context, apiKey: kGoogleApiKey, mode: Mode.fullscreen, ); return p; }, validator: (val) => val.isEmpty ? 'Enter address' : null, onChanged: (val) { setState(() => address = val); }, ),

    In Progress 
    opened by guijacobus2 6
  • Flutter master branch issue - The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.

    Flutter master branch issue - The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.

    For future release:

    If you are in the latest master branch of flutter the ios build fails with this error:

    ./../../../.pub-cache/hosted/pub.dartlang.org/flutter_google_places-0.2.6/lib/src/flutter_google_places.dart:74:15: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
         - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../../flutter/packages/flutter/lib/src/widgets/framework.dart').
        Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
              context.ancestorStateOfType(const TypeMatcher<PlacesAutocompleteState>());
                      ^^^^^^^^^^^^^^^^^^^
    
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel master, 1.26.0-2.0.pre.402, on macOS 11.1 20C69 darwin-x64, locale en-ZA)
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 4.1)
    [✓] IntelliJ IDEA Ultimate Edition (version 2020.3.1)
    [✓] Connected device (2 available)
    
    opened by Theunodb 6
  • Old version of rxdart

    Old version of rxdart

    Hi!

    Can you guys please update the version of rxdart?

    I'm getting this error: Because flutter_google_places 0.2.3 depends on rxdart ^0.22.0 and bkk_flutter depends on rxdart ^0.23.0, flutter_google_places 0.2.3 is forbidden.

    Thanks

    opened by sanisloandras 6
  • The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher.

    The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher.

    When I add this package to my flutter project, "The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher." i am getting the error.

    opened by yigitcevik 2
  •  Execution failed for task ':google_api_headers:compileDebugKotlin'.

    Execution failed for task ':google_api_headers:compileDebugKotlin'.

    As we know this package using the google_api_headers internally getting this build time error steps to regenerate: I m migrating my flutter apllication to android embedding v1 ti v2
    im at latest stable release of flutter_google_places and to solve this problem i also separately install . my apk have compileSDkversion 32,minSdkVersion 19,targetSDkVersion 31, ext.kotlin_version=1.5.10.

    in gradleWrapper property distributionUrl=https://services.gradle.org/distributions/gradle-6.5.1-all.zip

    opened by Mobigic-Vaibhav 0
  • Address filtration in autocomplete

    Address filtration in autocomplete

    I use autocomplete and I want to get results with addresses only.

    In the Android version of SDK, you can find TypeFilter.ADDRESS for that occasion (https://developers.google.com/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/TypeFilter)

    In the iOS version of SDK you have kGMSPlacesAutocompleteTypeFilterAddress (https://developers.google.com/maps/documentation/places/ios-sdk/reference/group___places_autocomplete_type_filter)

    I wasn't able to find in what list of types the mentioned constants are converting. Can anybody provide more details on how can I achieve address filtering through types? Thanks!

    opened by votruk 0
  • Add funcitonality to change color of Text in dialog list

    Add funcitonality to change color of Text in dialog list

    We are like to change to update the green color to black but there is no feature to update the color inside suggestion they are taking the default color of the theme.

    image

    opened by parmeetmaster 1
Releases(v0.4.0)
  • v0.4.0(Nov 23, 2022)

    NOTE: This version is not yet available on pub.dev due to #182. To use this version, add the following to your pubspec.yaml:

      flutter_google_places:
        git:
            url: https://github.com/fluttercommunity/flutter_google_places
            ref: v0.4.0
    

    New Features:

    • Add textStyle and borderRadius fields to PlacesAutocompleteField()
    • Add resultTextStyle to PlacesAutocompleteWidget()

    Other improvements:

    • Migrated flutter_lints to lint and applied all suggestions.
    • Updated rxdart to latest version.
    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Mar 15, 2022)

    0.3.2

    • Updated google_api_headers to 1.2.0

    0.3.1

    • Fixed null-pointer which caused the package to crash.
    • Upgrade example app to null safety
    • Applied flutter lints recommendations
    • Upgraded dependencies
    Source code(tar.gz)
    Source code(zip)
Owner
Flutter Community
A central place for all community made Flutter packages. To get started, see the README of the 'community' repository.
Flutter Community
This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with simple smooth animations, making a nice UI and UX.

search_map_place This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with

Lucas Bernardi 127 Oct 22, 2022
A migration of Google Maps Application with Flutter & Google Maps APIs including: Maps SDK for Android & IOS, Places API & polylines

google_maps A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

TAD 1 Mar 4, 2022
A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin

maps_demo A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin Getting Started Get an A

Gerry High 41 Feb 14, 2022
Flutter package to enable clustering of location markers on Google Maps using widgets specific to each location.

flutter_google_maps_widget_cluster_markers This widget implements a very specific adaptation of google_maps_cluster_manager, allowing different ,marke

Kek Tech 2 Jan 6, 2023
A plugin that offers widgets for Wear OS by Google

Flutter Wear Plugin A plugin that offers Flutter support for Wear OS by Google (Android Wear). To use this plugin you must set your minSdkVersion to 2

Flutter Community 114 Dec 18, 2022
Plugin for 'flutter_map' providing advanced caching functionality, with ability to download map regions for offline use. Also includes useful prebuilt widgets.

flutter_map_tile_caching A plugin for the flutter_map library to provide an easy way to cache tiles and download map regions for offline use. Installa

Luka S 69 Jan 3, 2023
Flutter Maps A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Salsabil Mohamed Hemada 1 Jul 15, 2022
A flutter plugin for Google Maps

IMPORTANT: This plugin is no longer under development Why? We initially built this plugin to fill an early gap in flutter. Since then, Google has made

AppTree Software, Inc 415 Dec 29, 2022
Flutter Google Maps Tutorial

Flutter Google Maps Tutorial YouTube Video Setup Get an API Key at https://cloud.google.com/maps-platform/ Enable Maps SDK for Android, Maps SDK for i

Marcus Ng 85 Nov 30, 2022
Flutter Tutorial - Google Map with Live Location Tracking

Flutter Tutorial - Google Map with Live Location Tracking Build Google Map app with Live Location Tracking in Flutter. ✌   App Preview Android Preview

Samuel Adekunle 10 Dec 22, 2022
Flutter Google Map Example - Day 41

Flutter Google Map Example - Day 41 class Afgprogrammer extends Flutter100DaysOfCode { video() { return { "title": "Flutter Google Map Exa

Mohammad Rahmani 74 Jan 3, 2023
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Youhaan bootwala 1 Mar 18, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Varun CN 2 Apr 19, 2022
Easy Google Maps for Flutter

easy_google_maps Easy Google Maps for Flutter on Web and Mobile Getting Started Mobile Follow setup for Mobile Here Web Good to go! EasyGoogleMaps(

Rody Davis 69 Jul 19, 2022
Flutter Google Map Example

Flutter Google Map Example A Flutter application demonstrate google map. Preview Listener and Marker Compass MapTypes Plugin google_maps_flutter from

Bhavik Makwana 67 Sep 14, 2021
Place picker on Google Maps for Flutter

Google Maps Place Picker A Flutter plugin which provides 'Picking Place' using Google Maps widget. The project relies on below packages. Map using Flu

Terry Kwon 178 Dec 16, 2022
How To Integrate Customized Google Map in Flutter

How To Integrate Customized Google Map in Flutter Let’s develop a customised Google Maps for the best user experience. Visit : https://medium.com/flut

Jaimil Patel 19 Dec 6, 2022
A car rental flutter application using firebase and google maps API

A car sharing & rental app using Flutter, Firebase & Google Maps APIs ?? About the App ?? hopOn is flutter based application for car sharing and renta

Shivani Singh 97 Dec 30, 2022
Simple flutter app demonstrating usage of Google Maps

flutter_maps_example Get an API key at GoogleCloud. Enable Google Map SDK for ea

Tornike Gogberashvili 0 Nov 23, 2022