google_maps_flutter | Flutter Package

google_maps_flutter 0.5.28+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

Google Maps for Flutter (Developers Preview) #

pub package

A Flutter plugin that provides a Google Maps widget.

Developers Preview Status #

The plugin relies on Flutter's new mechanism for embedding Android and iOS views. As that mechanism is currently in a developers preview, this plugin should also be considered a developers preview.

Known issues are tagged with the platform-views and/or maps labels.

To use this plugin on iOS you need to opt-in for 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.

The API exposed by this plugin is not yet stable, and we expect some breaking changes to land soon.

Usage #

To use this plugin, add google_maps_flutter as a dependency in your pubspec.yaml file.

Getting Started #

  • Get an API key at

  • Enable Google Map SDK for each platform.

    • Go to Google Developers Console.
    • Choose the project that you want to enable Google Maps on.
    • Select the navigation menu and then select "Google Maps".
    • Select "APIs" under the Google Maps menu.
    • To enable Google Maps for Android, select "Maps SDK for Android" in the "Additional APIs" section, then select "ENABLE".
    • To enable Google Maps for iOS, select "Maps SDK for iOS" in the "Additional APIs" section, then select "ENABLE".
    • Make sure the APIs you enabled are under the "Enabled APIs" section.
  • You can also find detailed steps to get start with Google Maps Platform here.

Android #

Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name=""
               android:value="YOUR KEY HERE"/>

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];

Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import GoogleMaps

@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: 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.

Both #

You can now add a GoogleMap widget to your widget tree.

The map view can be controlled with the GoogleMapController that is passed to the GoogleMap's onMapCreated callback.

Sample Usage #

import 'dart:async';

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

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

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Google Maps Demo',
      home: MapSample(),

class MapSample extends StatefulWidget {
  State<MapSample> createState() => MapSampleState();

class MapSampleState extends State<MapSample> {
  Completer<GoogleMapController> _controller = Completer();

  static final CameraPosition _kGooglePlex = CameraPosition(
    target: LatLng(37.42796133580664, -122.085749655962),
    zoom: 14.4746,

  static final CameraPosition _kLake = CameraPosition(
      bearing: 192.8334901395799,
      target: LatLng(37.43296265331129, -122.08832357078792),
      tilt: 59.440717697143555,
      zoom: 19.151926040649414);

  Widget build(BuildContext context) {
    return new Scaffold(
      body: GoogleMap(
        mapType: MapType.hybrid,
        initialCameraPosition: _kGooglePlex,
        onMapCreated: (GoogleMapController controller) {
      floatingActionButton: FloatingActionButton.extended(
        onPressed: _goToTheLake,
        label: Text('To the lake!'),
        icon: Icon(Icons.directions_boat),

  Future<void> _goToTheLake() async {
    final GoogleMapController controller = await _controller.future;

See the example directory for a complete sample app.

0.5.28+1 #

  • Android: Make sure map view only calls onDestroy once.
  • Android: Fix a memory leak regression caused in 0.5.26+4.

0.5.28 #

  • Android: Add liteModeEnabled option.

0.5.27+3 #

  • iOS: Update the gesture recognizer blocking policy to "WaitUntilTouchesEnded", which fixes the camera idle callback not triggered issue.
  • Update the min flutter version to 1.16.3.
  • Skip testTakeSnapshot test on Android.

0.5.27+2 #

  • Update lower bound of dart dependency to 2.1.0.

0.5.27+1 #

  • Remove endorsement of web platform, it's not ready yet.

0.5.27 #

  • Migrate the core plugin to use google_maps_flutter_platform_interface APIs.

0.5.26+4 #

  • Android: Fix map view crash when "exit app" while using FragmentActivity.
  • Android: Remove listeners from GoogleMap when disposing.

0.5.26+3 #

  • iOS: observe the bounds update for the GMSMapView to reset the camera setting.
  • Update UI related e2e tests to wait for camera update on the platform thread.

0.5.26+2 #

  • Fix UIKit availability warnings and CocoaPods podspec lint warnings.

0.5.26+1 #

  • Removes a errorneously added method from the GoogleMapController.h header file.

0.5.26 #

  • Adds support for toggling zoom controls (Android only)

0.5.25+3 #

  • Rename 'Page' in the example app to avoid type conflict with the Flutter Framework.

0.5.25+2 #

  • Avoid unnecessary map elements updates by ignoring not platform related attributes (eg. onTap)

0.5.25+1 #

  • Add takeSnapshot that takes a snapshot of the map.

0.5.25 #

  • Add an optional param mipmaps for BitmapDescriptor.fromAssetImage.

0.5.24+1 #

  • Make the pedantic dev_dependency explicit.

0.5.24 #

  • Exposed getZoomLevel in GoogleMapController.

0.5.23+1 #

  • Move core plugin to its own subdirectory, to prepare for federation.

0.5.23 #

  • Add methods to programmatically control markers info windows.

0.5.22+3 #

  • Fix polygon and circle stroke width according to device density

0.5.22+2 #

  • Update README: Add steps to enable Google Map SDK in the Google Developer Console.

0.5.22+1 #

  • Fix for toggling traffic layer on Android not working

0.5.22 #

  • Support Android v2 embedding.
  • Bump the min flutter version to 1.12.13+hotfix.5.
  • Fixes some e2e tests on Android.

0.5.21+17 #

  • Fix Swift example in

0.5.21+16 #

  • Fixed typo in LatLng's documentation.

0.5.21+15 #

  • Remove the deprecated author: field from pubspec.yaml
  • Migrate the plugin to the pubspec platforms manifest.
  • Require Flutter SDK 1.10.0 or greater.

0.5.21+14 #

  • Adds support for toggling 3D buildings.

0.5.21+13 #

  • Add documentation.

0.5.21+12 #

  • Update driver tests in the example app to e2e tests.

0.5.21+11 #

  • Define clang module for iOS, fix analyzer warnings.

0.5.21+10 #

  • Cast error.code to unsigned long to avoid using NSInteger as %ld format warnings.

0.5.21+9 #

  • Remove AndroidX warnings.

0.5.21+8 #

  • Add NSASSUME_NONNULL* macro to reduce iOS compiler warnings.

0.5.21+7 #

  • Create a clone of cached elements in GoogleMap (Polyline, Polygon, etc.) to detect modifications if these objects are mutated instead of modified by copy.

0.5.21+6 #

  • Override a default method to work around flutter/flutter#40126.

0.5.21+5 #

  • Update and migrate iOS example project.

0.5.21+4 #

  • Support projection methods to translate between screen and latlng coordinates.

0.5.21+3 #

  • Fix myLocationButton bug in google_maps_flutter iOS.

0.5.21+2 #

  • Fix more prefer_const_constructors analyzer warnings in example app.

0.5.21+1 #

  • Fix prefer_const_constructors analyzer warnings in example app.

0.5.21 #

  • Don't recreate map elements if they didn't change since last widget build.

0.5.20+6 #

  • Adds support for toggling the traffic layer

0.5.20+5 #

  • Allow (de-)serialization of CameraPosition

0.5.20+4 #

  • Marker drag event

0.5.20+3 #

  • Update Android play-services-maps to 17.0.0

0.5.20+2 #

  • Android: Fix polyline width in building phase.

0.5.20+1 #

  • Android: Unregister ActivityLifecycleCallbacks on activity destroy (fixes a memory leak).

0.5.20 #

  • Add map toolbar support

0.5.19+2 #

  • Fix polygons for iOS

0.5.19+1 #

  • Fix polyline width according to device density

0.5.19 #

  • Adds support for toggling Indoor View on or off.

  • Allow BitmapDescriptor scaling override

0.5.18 #

  • Fixed build issue on iOS.

0.5.17 #

  • Add support for Padding.

0.5.16+1 #

  • Update Dart code to conform to current Dart formatter.

0.5.16 #

  • Add support for custom map styling.

0.5.15+1 #

  • Add missing template type parameter to invokeMethod calls.
  • Bump minimum Flutter version to 1.5.0.
  • Replace invokeMethod with invokeMapMethod wherever necessary.

0.5.15 #

  • Add support for Polygons.

0.5.14+1 #

0.5.14 #

  • Adds onLongPress callback for GoogleMap.

0.5.13 #

  • Add support for Circle overlays.

0.5.12 #

  • Prevent calling null callbacks and callbacks on removed objects.

0.5.11+1 #

  • Android: Fix an issue where myLocationButtonEnabled setting was not propagated when set to false onMapLoad.

0.5.11 #

  • Add myLocationButtonEnabled option.

0.5.10 #

  • Support Color's alpha channel when converting to UIColor on iOS.

0.5.9 #

  • BitmapDescriptor#fromBytes accounts for screen scale on ios.

0.5.8 #

  • Remove some unused variables and rename method

0.5.7 #

  • Add a BitmapDescriptor that is aware of scale.

0.5.6 #

  • Add support for Polylines on GoogleMap.

0.5.5 #

  • Enable iOS accessibility.

0.5.4 #

  • Add method getVisibleRegion for get the latlng bounds of the visible map area.

0.5.3 #

  • Added support setting marker icons from bytes.

0.5.2 #

  • Added onTap for callback for GoogleMap.

0.5.1 #

  • Update Android gradle version.
  • Added infrastructure to write integration tests.

0.5.0 #

  • Add a key parameter to the GoogleMap widget.

0.4.0 #

  • Change events are call backs on GoogleMap widget.
  • GoogleMapController no longer handles change events.
  • trackCameraPosition is inferred from GoogleMap.onCameraMove being set.

0.3.0+3 #

  • Update Android play-services-maps to 16.1.0

0.3.0+2 #

  • Address an issue on iOS where icons were not loading.
  • Add apache http library required false for Android.

0.3.0+1 #

  • Add NSNull Checks for markers controller in iOS.
  • Also address an issue where initial markers are set before initialization.

0.3.0 #

  • Breaking change. Changed the Marker API to be widget based, it was controller based. Also changed the example app to account for the same.

0.2.0+6 #

  • Updated the sample app in

0.2.0+5 #

0.2.0+4 #

  • Fixed a crash when the plugin is registered by a background FlutterView.

0.2.0+3 #

  • Fixed a memory leak on Android - the map was not properly disposed.

0.2.0+2 #

  • Log a more detailed warning at build time about the previous AndroidX migration.

0.2.0+1 #

0.2.0 #

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.

0.1.0 #

  • Move the map options from the GoogleMapOptions class to GoogleMap widget parameters.

0.0.3+3 #

  • Relax Flutter version requirement to 0.11.9.

0.0.3+2 #

  • Update README to recommend using the package from pub.

0.0.3+1 #

  • Bug fix: custom marker images were not working on iOS as we were not keeping a reference to the plugin registrar so couldn't fetch assets.

0.0.3 #

  • Don't export dart:async.
  • Update the minimal required Flutter SDK version to one that supports embedding platform views.

0.0.2 #

  • Initial developers preview release.


// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'package:flutter/material.dart';
import 'package:google_maps_flutter_example/lite_mode.dart';
import 'animate_camera.dart';
import 'map_click.dart';
import 'map_coordinates.dart';
import 'map_ui.dart';
import 'marker_icons.dart';
import 'move_camera.dart';
import 'padding.dart';
import 'page.dart';
import 'place_circle.dart';
import 'place_marker.dart';
import 'place_polygon.dart';
import 'place_polyline.dart';
import 'scrolling_map.dart';
import 'snapshot.dart';

final List<GoogleMapExampleAppPage> _allPages = <GoogleMapExampleAppPage>[

class MapsDemo extends StatelessWidget {
  void _pushPage(BuildContext context, GoogleMapExampleAppPage page) {
        builder: (_) => Scaffold(
              appBar: AppBar(title: Text(page.title)),
              body: page,

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('GoogleMaps examples')),
      body: ListView.builder(
        itemCount: _allPages.length,
        itemBuilder: (_, int index) => ListTile(
          leading: _allPages[index].leading,
          title: Text(_allPages[index].title),
          onTap: () => _pushPage(context, _allPages[index]),

void main() {
  runApp(MaterialApp(home: MapsDemo()));

Use this package as a library

1. Depend on it

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

  google_maps_flutter: ^0.5.28+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:google_maps_flutter/google_maps_flutter.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 Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [google_maps_flutter] that is in a package requiring null.

Health suggestions

Fix lib/google_maps_flutter.dart. (-0.50 points)

Analysis of lib/google_maps_flutter.dart reported 1 hint:

line 18 col 8: Don't import implementation files from another package.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_plugin_android_lifecycle ^1.0.0 1.0.8
google_maps_flutter_platform_interface ^1.0.1 1.0.2
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
plugin_platform_interface 1.0.2
sky_engine 0.0.99
stream_transform 1.2.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
pedantic ^1.8.0
test ^1.6.0