flutter_google_places_api 0.0.13

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

Build Status

flutter_google_places_api #

An implementation of google place api

Getting started #

API key #

To get api key, follow instruction here

Places api types #

typesdescription
Find Placetakes a text input and returns a place.
Nearby Searchlets you search for places within a specified area.
Text Searchreturns information about a set of places based on a string — for example "pizza in New York" or "shoe stores near Ottawa" or "123 Main Street".
Place DetailsReturn detailed information about a specific place, including user reviews.
Place Photosgives you access to the millions of Place related photos stored in Google's Place database.
Place Autocompletecan be used to automatically fill in the name and/or address of a place as you type.
Query Autocompletecan be used to provide a query prediction service for text-based geographic searches, by returning suggested queries as you type.

Usage #

all places requests returns Future

Each request.call() will returns corresponding response!

Find Place

Find Place requires 'key', 'input' and 'inputtype' as default parameter.

'inputtype' must be either textquery or phonenumber.

for more parameters, check out here

//request returns corresponding response
FindPlaceResponse response = await FindPlaceRequest(
 key: 'YOUR_API_KEY_HERE',
 input: 'YOUT_INPUT_HERE',
 inputType: 'Either textquery or phonenumber'
).call();

print(response.toString());//will print response as json format

Nearby Search requires 'key', 'location' and 'radius' as default parameter.

For more parameters, check out here

//request returns corresponding response
NearbySearchResponse response = await NeaerbySearchRequest(
 key: 'YOUR_API_KEY_HERE',
 location: 'YOUT_LOCATION',
 radius: 'DISTANCE IN METERS'
).call();

print(response.toString());//will print response as json format

Text Search requires 'key' and 'query' as default parameter.

For more parameters, check out here

//request returns corresponding response
TextSearechResponse response = await TextSearchRequest(
 key: 'YOUR_API_KEY_HERE',
 query: 'YOUR_QUERY',
).call();

print(response.toString());//will print response as json format

Place Details

Details requires 'key' and 'place_id' as default parameter.

For more parameters, check out here

//request returns corresponding response
PlaceDetailsResponse response = await PlaceDetailsRequest(
 key: 'YOUR_API_KEY_HERE',
 placeId: 'PLACE_ID'
).call();

print(response.toString());//will print response as json format

Place Photo

place photo directly returns image of request. So if you want to use image in flutter with this package, there are two ways:

  1. use url with Image.network
  2. use bytes result with Image.memory

here is example of 1)

//this will extract url to get photo
String photoUrl = PlacePhotoRequest(
 key: 'YOUR_API_KEY_HERE',
 photoRefernce: 'PHOTO_REFERENCE_HERE'
 maxHeight: 400, //this value should be in 1~1600, default is 1600
 maxWidth: 400, //this value should be in 1~1600, default is 1600
).buildUrl();

/*---------In Widget-------------*/
Image.network(photoUrl);

and here is example of 2)

//this will return place photo response object
//PlacePhotoResponse only has one parameter : imageBytes
//use imageBytes in Image.memory!

PlacePhotoResponse reponse = await PlacePhotoRequest(
 key: 'YOUR_API_KEY_HERE',
 photoRefernce: 'PHOTO_REFERENCE_HERE'
 maxHeight: 400, //this value should be in 1~1600, default is 1600
 maxWidth: 400, //this value should be in 1~1600, default is 1600
).call();

/*---------In Widget-------------*/
Image.memory(response.imageByte);

Place Autocomplete

autocomplete requires 'input' and 'key' as default parameter

For more parameters, check out here

//request returns corresponding response
PlaceAutocompleteResponse response = await PlaceAutocompleteRequest(
 key: 'YOUR_API_KEY_HERE',
 input: 'YOUR_INPUT'
).call();

print(response.toStirng());//will print response as json format

Query Autocomplete

query autocomplete requires 'input' and 'key' as default parameter.

For more parameters, check out here

//request returns corresponding response
QueryAutocompleteResponse response = await QueryAutocompleteRequest(
 key: 'YOUR_API_KEY_HERE',
 input: 'YOUR_INPUT'
).call();

print(response.toStirng());//will print response as json format

Change Log #

0.0.1 #

First implementation of places api

0.0.11 #

Fixing all problems

0.0.12 #

Pretty format for flutter

0.0.13 #

Adding description

example/example.dart

import 'package:flutter_google_places_api/flutter_google_places_api.dart';

void main() async {
  var key = 'YOUR_API_KEY';
  var input = 'YOUR_INPUT_HERE';
  var response = await PlaceAutocompleteRequest(key: key, input: input).call();
  print(response.predictions[0].description);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_google_places_api: ^0.0.13

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_google_places_api/flutter_google_places_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
67
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_google_places_api that is a package requiring null.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
equatable ^1.1.1 1.2.0
flutter 0.0.0
http ^0.12.0+4 0.12.1
meta ^1.1.8 1.1.8 1.2.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
path 1.7.0
pedantic 1.9.0 1.9.1
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test
mockito ^4.1.1