Google places picker plugin for flutter. Opens up the google places picker on ios and android returning the chosen place back to the flutter app.

Overview

flutter_places_dialog

Shows a places picker dialog in ios and android, returning the data in the places picker to the app.

Getting Started

Generate your API Key

  1. Go to: https://console.developers.google.com/
  2. Enable Google Maps Android API
  3. Enable Google Maps SDK for iOS
  4. Under Credentials, choose Create Credential.
    • Note: For development, you can create an unrestricted API key that can be used on both iOS & Android. For production it is highly recommended that you restrict.

The way you register your API key on iOS vs Android is different. Make sure to read the next sections carefully.

iOS

The maps plugin will request your users location when needed. iOS requires that you explain this usage in the Info.plist file

  1. Set the NSLocationWhenInUseUsageDescription in ios/Runner/Info.plist. Example:
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Using location to display on a map</string>

Note: If your iOS and Android API key are different, be sure to use your iOS API key here.

  1. Add code to show the MapView.

    //Create an instance variable for the mapView
    var _place = await FlutterPlacesDialog.getPlacesDialog();
    
    
  2. Run your application on an iOS device or simulator. Confirm that when you display the map you see map detail. If you only see a beige screen it's possible that your API key is incorrect, or if it outright crashes.

Common API Key problems for iOS

  1. Your Bundle ID does not match what is registered in the Google API Console. When you create an restricted API key in the Google API console it asks you to specify your iOS bundle ID. Make sure that your iOS Bundle Identifier matches the one you registered in the console.

  2. Using the wrong key. If you made a separate key for iOS and Android, make sure you are using the iOS key in the MapView.setApiKey() call.

Android

You will be making multiple edits to your AndroidManifest.xml file. In your Flutter project, you can find this file location under android/app/src/main

  1. In your AndroidManifest.xml, add the following uses-permission above the tag.

        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  2. In your AndroidManifest.xml, add the following lines inside of the application tag. Be sure to replace your_api_key with the one you generated.

        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_api_key"/>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
  3. In your android/build.gradle file. Under buildScript dependencies add:

        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
  4. Run your application on an Android device or simulator. Confirm that when you display the map you see map detail. If you only see a beige screen it's possible that your API key is incorrect.

Features

  • iOS Support
  • Android Support

Usage examples

Show the places picker ( with autocomplete )

  PlaceDetails place = await FlutterPlacesDialog.getPlacesDialog();

FAQ

Dialog shows up and drops almost immediately

Verify you have your google api key setup correctly. If using iOS you need to set this via the API call, on android you need to setup the google-services.json correctly in your app deployment or it will not correctly show the screen, dropping out basically immediately. You should get an error back from the api call to the client saying it dropped.

Comments
  • Crash after opening picker

    Crash after opening picker

    I created a brand new flutter app with Kotlin support. I configured everything according to README. I'm using the main.dart from the example. App starts. When i klick on "Pick" it opens the picker for half a second, then crashes:

    Launching lib/main.dart on MyDevice in debug mode...
    Initializing gradle...
    Resolving dependencies...
    Running 'gradlew assembleDebug'...
    Skipping compilation. Fingerprint match.
    Built build/app/outputs/apk/debug/app-debug.apk (33.6MB).
    I/FlutterActivityDelegate(22909): onResume setting current activity to this
    I/flutter (22909): Initialized api key AIzaSyA5vzdfghjklö841236842SMhRYqo true
    Syncing files to device MyDevice...
    I/FlutterActivityDelegate(22909): onResume setting current activity to this
    D/AppTracker(22909): App Event: start
    I/vndksupport(22909): sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.
    E/        (22909): Cannot load libgui-plugin
    I/flutter (22909): Opening places dialog
    D/AppTracker(22909): App Event: stop
    E/AndroidRuntime(22909): FATAL EXCEPTION: main
    E/AndroidRuntime(22909): Process: com.example.flutterlocationdialog, PID: 22909
    E/AndroidRuntime(22909): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=42, result=2, data=null} to activity {com.example.flutterlocationdialog/com.example.flutterlocationdialog.MainActivity}: java.lang.NullPointerException: intent must not be null
    E/AndroidRuntime(22909): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4528)
    E/AndroidRuntime(22909): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4571)
    E/AndroidRuntime(22909): 	at android.app.ActivityThread.-wrap19(Unknown Source:0)
    E/AndroidRuntime(22909): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
    E/AndroidRuntime(22909): 	at android.os.Handler.dispatchMessage(Handler.java:105)
    E/AndroidRuntime(22909): 	at android.os.Looper.loop(Looper.java:164)
    E/AndroidRuntime(22909): 	at android.app.ActivityThread.main(ActivityThread.java:6809)
    E/AndroidRuntime(22909): 	at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(22909): 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    E/AndroidRuntime(22909): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    E/AndroidRuntime(22909): Caused by: java.lang.NullPointerException: intent must not be null
    E/AndroidRuntime(22909): 	at com.google.android.gms.common.internal.zzbq.checkNotNull(Unknown Source:8)
    E/AndroidRuntime(22909): 	at com.google.android.gms.location.places.ui.zza.getStatus(Unknown Source:2)
    E/AndroidRuntime(22909): 	at com.google.android.gms.location.places.ui.PlaceAutocomplete.getStatus(Unknown Source:0)
    E/AndroidRuntime(22909): 	at com.example.flutterplacesdialog.FlutterPlacesDialogPlugin.onActivityResult(FlutterPlacesDialogPlugin.kt:98)
    E/AndroidRuntime(22909): 	at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:194)
    E/AndroidRuntime(22909): 	at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139)
    E/AndroidRuntime(22909): 	at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:128)
    E/AndroidRuntime(22909): 	at android.app.Activity.dispatchActivityResult(Activity.java:7267)
    E/AndroidRuntime(22909): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4524)
    E/AndroidRuntime(22909): 	... 9 more
    D/AppTracker(22909): App Event: crash
    

    Gradle: 4.4 SdkVersion: 27

    opened by barredterra 6
  • Unable to build for XCode 9.0

    Unable to build for XCode 9.0

    Hello All, first of, THANK YOU so much for your hard work on this package. I am a newby to any kind of frontend development and am amazed as to how fast I can get stuff working with packages, specially this one!

    I am using XCode 9 because that is what Flutter recommended. At this time, I am only running the sample project from flutter and your package. Nothing fancy. It works great for Android, but when I try to compile for iOS to see it in the simulator, I get the following message:

    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
        
    Xcode's output:
    ↳
        === BUILD TARGET flutter_places_dialog OF PROJECT Pods WITH CONFIGURATION Debug ===
        The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
    Could not build the application for the simulator.
    Error launching application on iPhone 7.
    

    Does the library need to be eventually upgraded to XCode 9, or would this be something misconfigured on my dev env?

    opened by jarias14 1
  • Bump the version of google play services to 15.0.1

    Bump the version of google play services to 15.0.1

    Closes #6

    I successfully built my own app.

    dependencies:
      flutter:
        sdk: flutter
      map_view: ^0.0.14
      flutter_places_dialog:
        git: 'https://github.com/kdy1/flutter_places_dialog.git'
      flutter_google_places_autocomplete: ^0.1.1+1
      firebase_auth: "0.5.20"
      google_sign_in: "3.0.5"
      cloud_firestore: '0.8.0'
    
    
    opened by kdy1 0
  • Android dependency version

    Android dependency version

    
    Failed to capture snapshot of input files for task ':flutter_places_dialog:compileDebugAidl' property 'importDirs' during up-to-date check.
    > The library com.google.android.gms:play-services-base is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 15.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
    
    
    opened by kdy1 0
  • Unable to build IOS

    Unable to build IOS

    Hi, Android build was completely fine and was able to release. However IOS I'm getting this error...

    === BUILD TARGET FirebaseFirestore OF PROJECT Pods WITH CONFIGURATION Release === /Users/Leo/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_places_dialog-1.0.3/ios/Classes/SwiftFlutterPlacesDialogPlugin.swift:41:11: warning: 'catch' block is unreachable because no errors are thrown in 'do' block } catch { ^ /Users/Leo/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_places_dialog-1.0.3/ios/Classes/SwiftFlutterPlacesDialogPlugin.swift:41:11: warning: 'catch' block is unreachable because no errors are thrown in 'do' block } catch { ^ === BUILD TARGET FirebaseFunctions OF PROJECT Pods WITH CONFIGURATION Release === /Users/Leo/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_places_dialog-1.0.3/ios/Classes/FlutterPlacesDialogPlugin.m:3:9: fatal error: 'flutter_places_dialog/flutter_places_dialog-Swift.h' file not found #import <flutter_places_dialog/flutter_places_dialog-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

    opened by 9thwall 3
  • Preselecting users location area

    Preselecting users location area

    Currently, when I open the dialog, the map starts in some random location. I was wondering if there was a way to get the users current location and inject this to the dialog so the map doesn't default to some random place and opened with a map around the users current location.

    opened by 9thwall 2
Owner
null
OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal

OneSignal Flutter SDK OneSignal is a free push notification service for mobile apps. This SDK makes it easy to integrate your Flutter iOS and/or Andro

OneSignal 556 Nov 17, 2022
Flutter package for makes it easy to integrate dialogflow and support dialogflow v2

Dialogflow v1 & v2 for Flutter apps. ❤️ Star ❤️ the repo to support the project. Thanks! A new Flutter package. Example Awesome Tutorials Flutter and

Victor Alfonso Rodas Oña 206 Nov 13, 2022
Liquidart is a Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider. Revival of the abandoned AQUEDUCT project.

Liquidart is a modern Dart HTTP server framework. The framework is composed of libraries for handling and routing HTTP requests, object-relational map

Aldrin's Art Factory 36 Oct 4, 2022
Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.

Aqueduct is a modern Dart HTTP server framework. The framework is composed of libraries for handling and routing HTTP requests, object-relational mapp

Abdelrahman Saed 2 Jul 7, 2021
Google Places - Google places autocomplete widgets for flutter.

flutter_google_places Google places autocomplete widgets for flutter. Getting Started For help getting started with Flutter, view our online documenta

Flutter Community 261 Nov 24, 2022
An app that opens Facebook, Google, Youtube by Click on the navigation bar items specifically for each.

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

dev_allauddin 3 Feb 3, 2022
Cupertino back gesture - Flutter package to set custom width of iOS back swipe gesture area

cupertino_back_gesture A Flutter package to set custom width of iOS back swipe gesture area. Usage To use this package, add cupertino_back_gesture as

null 26 May 25, 2022
Tahseen Quraishi 20 Dec 3, 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
Simple project that consumes the World Time APi and displays the time for the chosen location.

World Time App Simple project that consumes the World Time APi and displays the time for the chosen location. Web Api WorldTime Technologies Flutter A

Mario Vieria 1 Jan 20, 2022
LakhanKumawat ᵖ⁺ 12 Nov 7, 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
News app returning tech, health, sports and general news from newsapi.org

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

Grace Youpele 5 Nov 15, 2022
Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects

Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects This package is a ready-to-use API for Elastic

Julien Le Bren 5 Nov 16, 2022
Place picker for Flutter using open street, Here maps and google map

Flutter Place Picker A Flutter plugin which provides 'Picking Place' using Open Street, Here Maps and Google Maps widget. Much thanks to Terry Kwon Th

Samuel Annin Yeboah 15 Oct 27, 2022
Video player-2.2.10 - A Flutter plugin for iOS, Android and Web for playing back video on a Widget surface

Video Player plugin for Flutter A Flutter plugin for iOS, Android and Web for pl

null 2 Sep 29, 2022
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 179 Dec 2, 2022
A Flutter plugin which provides 'Picking Place' using Google Maps widget

Google Maps Places Picker Refractored This is a forked version of google_maps_place_picker package, with added custom styling and features.

Varun 5 Nov 13, 2022
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