Location picker for Flutter.

Related tags

Map dart maps flutter
Overview

Flutter Place Picker Pub

The missing location picker made in Flutter for Flutter. With dark theme and custom localization support.

⚠️ Please note: This library will NOT be affected by the deprecation of Place Picker as indicated here.

🍭 Remember to enable Places API, Maps SDK for Android, Maps SDK for iOS and Geocoding API for your API key.

Usage

To use this plugin, add place_picker as a dependency in your pubspec.yaml file.

Getting Started

This package relies on google_maps_flutter to display the map. Follow these guidelines to add your API key to the Android and iOS packages.

Get an API key at https://cloud.google.com/maps-platform/ if you haven't already.

Android

Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml and add ACCESS_FINE_LOCATION permission:

<manifest ...

  <!-- Add this permission -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

  <application ...
    <!-- Add your api key here -->
    <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="YOUR KEY HERE"/>
    <activity ..../>
  </application>
</manifest>

Update your gradle.properties file with this:

android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M

Please also make sure that you have those dependencies in your build.gradle:

  // parent level build.gradle (android/build.gradle)
  dependencies {
      classpath 'com.android.tools.build:gradle:3.3.0'
      classpath 'com.google.gms:google-services:4.2.0'
  }
  ...

  // app level build.gradle (android/app/build.gradle)
  compileSdkVersion 28

iOS

Specify your API key in the application delegate ios/Runner/AppDelegate.m:

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "GoogleMaps/GoogleMaps.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GMSServices provideAPIKey:@"YOUR KEY HERE"];
  [GeneratedPluginRegistrant registerWithRegistry:self];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("YOUR KEY HERE")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

info.plist

Also add these to the dict values in Info.plist for location request to work on iOS info.plist

Sample Usage

Import the package into your code

import 'package:place_picker/place_picker.dart';

Create a method like below, and call it in onTap of a button or InkWell. A LocationResult will be returned with the name and lat/lng of the selected place. You can then handle the result in any way you want. Pass in an optional LatLng displayLocation to display that location instead. This is useful when you want the map to display the previously selected location.

void showPlacePicker() async {
    LocationResult result = await Navigator.of(context).push(MaterialPageRoute(
        builder: (context) =>
            PlacePicker("YOUR API KEY",
                        displayLocation: customLocation,
                        )));

    // Handle the result in your way
    print(result);
}
Comments
  • Result is null

    Result is null

    Hi.

    I'm having troubles with picking a location, is always returning null. I checked #14 and #24, I already have Geocoding enabled.

    A RangeError message always shows when selecting a location.

    RangeError (index): Invalid value: Valid value range is empty: 0
    

    flutter doctor:

    [✓] Flutter (Channel stable, v1.17.0, on Linux, locale en_US.UTF-8)
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc1)
    [✓] Android Studio (version 3.6)
    [✓] VS Code (version 1.44.2)
    [✓] Connected device (1 available)
    
    • No issues found!
    
    opened by pblinux 26
  • after upgrade flutter 2.2.3 to 2.5.0 i got this error

    after upgrade flutter 2.2.3 to 2.5.0 i got this error

    /E:/Andriod/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/rich_suggestion.dart:35:89: Error: The getter 'body1' isn't defined for the class 'TextTheme'.

    • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/E:/Andriod/flutter/packages/flutter/lib/src/material/text_theme.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'body1'. TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.body1.color)), ^^^^^ /E:/Andriod/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/search_input.dart:60:65: Error: The getter 'body1' isn't defined for the class 'TextTheme'.
    • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/E:/Andriod/flutter/packages/flutter/lib/src/material/text_theme.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'body1'. Icon(Icons.search, color: Theme.of(context).textTheme.body1.color), ^^^^^

    FAILURE: Build failed with an exception.

    • Where: Script 'E:\Andriod\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

    • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

    Process 'command 'E:\Andriod\flutter\bin\flutter.bat'' finished with non-zero exit value 1

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    • Get more help at https://help.gradle.org

    BUILD FAILED in 1m 8s

    opened by Sreejith93 9
  • Location result is coming null

    Location result is coming null

    Hello, I have been using your package for a while now. It was working fine till now. But from last few days i'm not getting the place result. Its giving me null & i'm not getting any exception too. Place picker is showing the current location and nearby places correctly, but not the selected location details. Help me to figure out what could be the issue.

    Below is the attachment where you can see that the place details is showing as Unnamed location. error

    opened by nvamsi214 8
  • fix: TextTheme.body1 was replaced by bodyText1 as it failed in newer versions

    fix: TextTheme.body1 was replaced by bodyText1 as it failed in newer versions

    Hey there!

    I use this plugin on a project at work, we just updated Flutter, and the build failed because of invalid TextTheme property body1.

    Description

    Replaces TextTheme.body1 with TextTheme.bodyText1

    PD: Are you maintaining the project? or would I be able to help out? Otherwise is there any problem in me making a clone so I can maintain it for work?

    opened by nombrekeff 5
  • Feature/localization

    Feature/localization

    I added a new localization file with default english setting. When someone wants it to have in a different language, he can send a long a localized LocalizationItem with the appropriate language_code. Then also the google maps api search results will be translated accordingly.

    the second commit is to have a back button in the appBar. In case you want to go back without a selection. Of course you can ignore the second commit, then I will put the place_picker in its own scaffold and put an appbar on top of it to have the back button 👍

    thx for checking my enhancement and wish you a lovely day. cheers dave

    opened by daverupp 5
  • Localization

    Localization

    @blackmann thx for the super work One question. I see the english string hard coded in the code. Is it possible to expose these values to the constructor of PlacePicker so I can actually localize the widget?

    would be super cool if you could do that... Would love to use this super nice widget.

    opened by daverupp 5
  • Refactor and Code split

    Refactor and Code split

    I didn't really refactor much though. I just felt the need separate the widgets so I could see clearly.

    We could still refactor to improve code quality and review together. One way is introducing a lint file.

    NB: I use a line width of 120. Makes code more readable.

    opened by jogboms 4
  • Crash on 2nd open

    Crash on 2nd open

    image

        final result = await Navigator.of(context).push(MaterialPageRoute(
          builder: (context) =>
            Theme(
              data: Theme.of(context).copyWith(
                accentColor: Colors.black
              ),
              child: PlacePicker(Api.googleKey),
            ) 
          )
        );
    
    opened by festelo 4
  • Issues when using the dark theme.

    Issues when using the dark theme.

    Screenshot_20191208-171837

    When using dark theme the text is not visible anymore.

    Code to reproduce this:

        return MaterialApp(
          title: 'Google Maps',
          darkTheme: ThemeData.dark(),
          theme: ThemeData.dark(),
          home: Home(),
        );
    
    opened by dariotrombello 3
  • OVER_QUERY_LIMIT Issue from google

    OVER_QUERY_LIMIT Issue from google

    Hi i am having used your plugins and i have created new API and enable all service which is required. but not sure what is issue always throw this error

    Can you suggest me where i am wrong?

    I/Google Maps Android API( 4432): Google Play services package version: 18382021 I/flutter ( 4432): { I/flutter ( 4432): "error_message" : "You have exceeded your daily request quota for this API. If you did not set a custom daily request quota, verify your project has an active billing account: http://g.co/dev/maps-no-account", I/flutter ( 4432): "results" : [], I/flutter ( 4432): "status" : "OVER_QUERY_LIMIT" I/flutter ( 4432): } I/flutter ( 4432): RangeError (index): Invalid value: Valid value range is empty: 0

    opened by pmrajani 3
  • updated dependencies, bug fixes

    updated dependencies, bug fixes

    Updated dependencies to latest. (location, google_maps_flutter and http)

    Added a loading progress until map view is created.

    Fixed #39 , #75

    Revised PR of #76

    opened by sartajroshan 2
  • Location result does not have all the informations

    Location result does not have all the informations

    Hi,

    I would like to access all the information shared by google : https://developers.google.com/maps/documentation/places/web-service/details

    the international_phone_number for exemple.

    but in the result we have limited informations

    opened by Yanaus 0
  • When using

    When using "Restrict usage on Google Cloud" API stops working

    Everything works fine until I restrict the API usage to Android apps with my SHA1 signature, which works for all other packages I am using, namely the google_maps_flutter plugin, which uses that same API key.

    api
    opened by fulcus 0
  • App crashes in Android after searching and picking a location

    App crashes in Android after searching and picking a location

    After a location is searched in the search field of the place picker view, it is selected and comes back to the previous page, app crashes. The log is given below.

    E/AndroidRuntime(11487): FATAL EXCEPTION: GLThread 1254 E/AndroidRuntime(11487): Process: com.app., PID: 11487 E/AndroidRuntime(11487): java.lang.NullPointerException: Attempt to get length of null array E/AndroidRuntime(11487): at java.nio.ByteBufferAsIntBuffer.put(ByteBufferAsIntBuffer.java:122) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.i(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):2) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.d(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):3) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.d.s(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):2) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ao.s(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):12) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.bz.s(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):29) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.bs.b(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):151) E/AndroidRuntime(11487): at com.google.maps.api.android.lib6.gmm6.vector.av.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100700-0):48) D/TransportRuntime.JobInfoScheduler(11487): Scheduling upload for context TransportContext(cct, HIGHEST, MSRodHRwczovL2NyYXNobHl0aWNzcmVwb3J0cy1wYS5nb29nbGVhcGlzLmNvbS92MS9maXJlbG9nL2xlZ2FjeS9iYXRjaGxvZ1xBSXphU3lCcnBTWVQ0RkZMMDlyZUhKaTZIOUZZZGVpU25VVE92Mk0=) with jobId=1506946804 in 1000ms(Backend next call timestamp 1660743691856). Attempt 1 W/com.app.(11487): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) W/com.app.(11487): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) W/com.app.(11487): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) W/com.app.(11487): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) W/com.app.**(11487): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) I/Process (11487): Sending signal. PID: 11487 SIG: 9 Lost connection to device.

    opened by rijazrasheed 0
  • LocationResult return null

    LocationResult return null

    result = await Navigator.of(context).push(MaterialPageRoute( builder: (context) => PlacePicker(keyMap, displayLocation: LatLng(lat,lon), )));

    print(result);
    
    opened by s2yed 4
Owner
Degreat
I can draw. I can't code. 😕
Degreat
🌍 Map location picker component for flutter Based on google_maps_flutter

google_map_location_picker Location picker using the official google_maps_flutter. I made This plugin because google deprecated Place Picker. Using Pu

Ibrahim Eid 189 Dec 5, 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
A Flutter package for iOS and Android for picking location and images.

location and image picker package for Flutter A Flutter package for iOS and Android for picking location and images. Demo Installation First, add loca

sk shamimul islam 9 Sep 28, 2022
A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

Flutter Location Plugin This plugin for Flutter handles getting a location on Android and iOS. It also provides callbacks when the location is changed

Guillaume Bernos 953 Dec 22, 2022
Flutter application to share location with a group. (under development)

Beacon About the Project This project is a flutter build native interface to ease the group travelling (or hiking). By using this, the group leader wo

CCExtractor Development 29 Nov 30, 2022
An Android App, which lets you work on Location Data, built with :heart: using Flutter

locatorz A Simple Flutter based Android Application to work with Location based Data ;) Documentation :: Work in Progress :) Screenshots :: Screen Rec

Anjan Roy 31 Aug 23, 2022
Flow is a water source location app that helps students of the University of Bamenda, Bambili to find/locate clean water sources.

Flow is a water source location mobile app that helps students of the University of Bamenda, Cameroon to find/locate clean water sources.

DSC UBa 12 Oct 21, 2022
DinoRide allows you to book a trip and have dinosaurs deliver you to your desired location!

DinoRide ?? Inspiration We wanted to reimagine a modern app in a prehistoric context. We thought a taxi service but with dinosaurs would have been fun

Westdale Software Dev Club 1 Jun 30, 2022
flutter_map plugin to request and display the users location and heading on the map

The plugin is discontinued. Feel free to fork it or checkout similar plugins. Flutter Map – Location plugin A flutter_map plugin to request and displa

Fabian Rosenthal 19 Oct 11, 2022
Map Picker for Flutter

Map Pin Picker A Vendor-free map Library for Easy and Quick Usage. Follow the steps to integrate Google Maps (https://pub.dev/packages/google_maps_flu

Akbar 16 Jul 15, 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 178 Dec 16, 2022
A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

Boris Gautier 5 Sep 14, 2022
Flutter Community - A central place for community made Flutter content.

Flutter Community A central place for community made Flutter content. The Flutter Community is an organization aimed at providing a central place for

Flutter Community 1.3k Jan 1, 2023
MapBox-GL-flutter - MapBox GL flutter package

MapBox GL - Flutter This app use MapBox If you want to run this code, please rep

Brandon Rojas 2 May 29, 2022
Mapbox-flutter - A repository to demonstrate the use of Mapbox - it's Maps and Navigation SDKs in a Flutter application

MapBox Flutter This repository contains code corresponding to the Youtube video

AB Satyaprakash 39 Dec 30, 2022
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 plugin for forward and reverse geocoding

geocoder Forward and reverse geocoding. Usage Import package:geocoder/geocoder.dart, and use the Geocoder.local to access geocoding services provided

Aloïs Deniel 177 Dec 31, 2022
Moved to https://github.com/tobrun/flutter-mapbox-gl

Please note that this project has moved. Please head to https://github.com/tobrun/flutter-mapbox-gl for updates. Flutter Mapbox GL Native This Flutter

Mapbox 258 Oct 16, 2022