Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter place picker

location picker for flutter.

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.

location picker

also add these to the dict values in info.plist for location request to work on ios
info.plist

sample usage for location picker

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.

void showplacepicker() async {
    locationresult result = await navigator.of(context).push(materialpageroute(
        builder: (context) =>
            placepicker("your api key")));
    
    // handle the result in your way
    print(result);
}

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.