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 that means you need to use await/async.

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

Libraries

address_component
candidate
components
day_time
debug_log
find_place_request
find_place_response
flutter_google_places_api
flutter_google_places_api.models
flutter_google_places_api.requests
flutter_google_places_api.responses
geometry
location
matched_substrings
model
nearby_search_request
nearby_search_response
nearby_search_result
opening_hours
period
photo
place_autocomplete_request
place_autocomplete_response
place_details_request
place_details_response
place_details_result
place_photos_request
place_photos_response
place_prediction
place_response
place_status
places_request
plus_code
query_autocomplete_request
query_autocomplete_response
query_prediction
review
structured_formatting
term
text_search_request
text_search_response
text_search_result
viewport