• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    Dart
  • License
    Other
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Location picker for Flutter.

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);
}

More Repositories

1

story_view

Story view for apps with stories.
Dart
357
star
2

go-gurl

Curl TUI with Go as Postman replacement
Go
84
star
3

overlapping_panels

Discord inspired navigation for Flutter apps
Dart
43
star
4

stylebender

No code style generator for fast moving indie web developers
TypeScript
33
star
5

3e

Next level 3d workflow inside VSCode.
TypeScript
16
star
6

gnewsclone

Google News Clone
Dart
10
star
7

storyexample

Library example for story_view : https://github.com/blackmann/story_view.git
Dart
10
star
8

ManyThings

Swift
9
star
9

socdn

Self hosted file server
CSS
6
star
10

fonted

Change workspace font for vscode
TypeScript
6
star
11

overlapping_panels_demo

Demo for overlapping_panels Flutter library
Dart
5
star
12

Wipe_Modules

Swift
5
star
13

wardrobe

Styled React βš›οΈ components to quickly bootstrap ideas.
TypeScript
5
star
14

react-chat-input

The missing chat input for React βš›οΈ
TypeScript
4
star
15

mit6006

Software Engineering Journey. I may document
Kotlin
3
star
16

tinyrenderer

Go
2
star
17

zig-sdl-3d-renderer

Zig
1
star
18

matter-experiments

MatterJS experiments
JavaScript
1
star
19

MCC-USSD

MCC USSD
Python
1
star
20

doctor

Opensource docx editor based on Facebook lexical
TypeScript
1
star
21

analog-display

Analog display experiment
JavaScript
1
star
22

SpaceShooter

GDScript
1
star
23

chillnerds

TypeScript
1
star
24

js-react-frontend-test

JavaScript
1
star
25

json

Custom JSON Placeholder server
JavaScript
1
star
26

blackmann.github.io

Home of the Super Creative πŸ„πŸ½
Astro
1
star
27

jsjsx

An idea worth exploring
JavaScript
1
star
28

blackmann

Haha, github says I discovered this secret
1
star
29

resteasy

Go
1
star
30

home-archive-2022-01

My home page now built with rust
Rust
1
star
31

ousa

An app to take account of contributions made by old students of Universal 2010
Python
1
star
32

c001start

Code competition 1 for the Boyssss
JavaScript
1
star
33

ekikiyen

This is an enhancement of the Ekiki Me promo from Vodafone
Java
1
star