flutter_places_autocomplete 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

flutter_places_autocomplete_example #

A plugin that give you the access to google places api to search by geolocation and places to autocomplete.

Features #

  • Generate a list of locations based on user input and optional parameters;
  • Get Geolocation (lat, lng) from a place, based on place_id

Usage #

In order to use this plugin you need to add flutter_places_autocomplete to your pubspec.yaml file.

    flutter_places_autocomplete: 0.1.0 

Geolocation #

You can get the place Geolocation by passing it's placeId. for example:

import 'package:flutter_places_autocomplete/flutter_places_autocomplete.dart';

Geolocation geolocation = await PacesAutocomplete(apikey: 'YOUR_API_KEY').getGeolocation(placeId: 'ChIJdd4hrwug2EcRmSrV3Vo6llI');

You can also retrive the the geolocation in string format lat,lng:

Geolocation geolocation = await PacesAutocomplete(apikey: 'YOUR_API_KEY').getGeolocation(placeId: 'ChIJdd4hrwug2EcRmSrV3Vo6llI');


You can also set optional parameters to the search

fieldsYou can specify which fields of the search you want to bring.
sessionTokenA random string which identifies an autocomplete session for billing purposes

The Basic category includes the following fields: address_component, adr_address, formatted_address, geometry, icon, name, permanently_closed, photo, place_id, plus_code, type, url, utc_offset, vicinity

The Contact category includes the following fields: formatted_phone_number, international_phone_number, opening_hours, website

The Atmosphere category includes the following fields: price_level, rating, review, user_ratings_total

Predictions #

You can retrieve a list of possible predictions for an input. for example:

import 'package:flutter_places_autocomplete/flutter_places_autocomplete.dart';

Predictions predictions = await PacesAutocomplete(apikey: 'YOUR_API_KEY').gerPredictions(input: 'London');

It will retrieve a List<Prediction> which contains

descriptionThe human-readable name for the returned result.
place_idA textual identifier that uniquely identifies a place.
typesAn array of types that apply to this place.
termsAn array of terms identifying each section of the returned description
geolocationA geolocation object containing lat, lng for the place

You can set the following parameters:

languageThe language code, indicating in which language the results should be returned
locationThe point around which you wish to retrieve place information. Must be specified as lat,lng.
typesThe types of place results to return.
strictboundsPlaces that are strictly within the region defined by location and radius

[0.1.1] #

  • Set flutter SDK version

[0.1.0] #

  • Initial alpha release


import 'package:flutter_places_autocomplete/flutter_places_autocomplete.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Places Autocomplete',
      home: MyApp(),

class FlutterPlacesAutocompleteWidget extends StatefulWidget {
  FlutterPlacesAutocompleteWidget({Key key}) : super(key: key);

  _FlutterPlacesAutocompleteWidgetState createState() =>

class _FlutterPlacesAutocompleteWidgetState
    extends State<FlutterPlacesAutocompleteWidget> {
  PlacesAutocomplete placesAutocomplete;
  List<Prediction> predictions;
  final searchController = TextEditingController();

  void initState() {
    placesAutocomplete =
        PlacesAutocomplete(apiKey: 'AIzaSyC-OHeGgrRHWqf3gkMWAKvd6yvJKpvv6xM');
    predictions = [];

  void dispose() {
    // Clean up the controller when the widget is disposed.

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Places Autocomplete'),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
              controller: searchController,
              onPressed: _fetchPredictions,
              child: Text(
                style: TextStyle(fontSize: 20),

  Future<void> _fetchPredictions() async {
    setState(() async {
      predictions = await placesAutocomplete.getPreditcions(input: 'london');

  Widget _listView() {
    return ListView.builder(
        itemCount: predictions.length,
        itemBuilder: (BuildContext ctxt, int index) {
          return new Text(predictions[index].description);

Use this package as a library

1. Depend on it

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

  flutter_places_autocomplete: ^0.1.1

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_places_autocomplete/flutter_places_autocomplete.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:flutter_places_autocomplete/flutter_places_autocomplete.dart]

Package does not support Flutter platform macos

Because of import path [package:flutter_places_autocomplete/flutter_places_autocomplete.dart]

Package does not support Flutter platform web

Because of import path [package:flutter_places_autocomplete/flutter_places_autocomplete.dart]

Package does not support Flutter platform windows

Because of import path [package:flutter_places_autocomplete/flutter_places_autocomplete.dart]

Package not compatible with SDK dart

because of import path [flutter_places_autocomplete]

Health issues and suggestions

Document public APIs. (-0.52 points)

61 out of 62 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/places_impl.dart. (-1 points)

Analysis of lib/src/places_impl.dart reported 2 hints:

line 6 col 16: Name non-constant identifiers using lowerCamelCase.

line 8 col 16: Name non-constant identifiers using lowerCamelCase.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
equatable ^1.0.2 1.2.0
flutter 0.0.0
http ^0.12.0+4 0.12.1
meta ^1.1.8 1.1.8
mockito ^4.1.1 4.1.1
Transitive dependencies
async 2.4.1
boolean_selector 2.0.0
charcode 1.1.3
collection 1.14.12
http_parser 3.1.4
matcher 0.12.6
path 1.7.0
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.7.0
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.16
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies