tree: eb2a77452b397c3e8e800e4d94bd8e9fe4fc76e2 [path history] [tgz]
  1. android/
  2. example/
  3. lib/
  4. test/
  5. AUTHORS
  6. CHANGELOG.md
  7. LICENSE
  8. pubspec.yaml
  9. README.md
packages/google_maps_flutter/google_maps_flutter_android/README.md

google_maps_flutter_android

The Android implementation of google_maps_flutter.

Usage

This package is endorsed, which means you can simply use google_maps_flutter normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.

However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.

Display Mode

This plugin supports two different platform view display modes. The default display mode is subject to change in the future, and will not be considered a breaking change, so if you want to ensure a specific mode you can set it explicitly:

import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

void main() {
  // Require Hybrid Composition mode on Android.
  final GoogleMapsFlutterPlatform mapsImplementation =
      GoogleMapsFlutterPlatform.instance;
  if (mapsImplementation is GoogleMapsFlutterAndroid) {
    mapsImplementation.useAndroidViewSurface = true;
  }
  // ···
}

Hybrid Composition

This is the current default mode, and corresponds to useAndroidViewSurface = true. It ensures that the map display will work as expected, at the cost of some performance.

Texture Layer Hybrid Composition

This is a new display mode used by most plugins starting with Flutter 3.0, and corresponds to useAndroidViewSurface = false. This is more performant than Hybrid Composition, but currently misses certain map updates.

This mode will likely become the default in future versions if/when the missed updates issue can be resolved.

Map renderer

This plugin supports the option to request a specific map renderer.

The renderer must be requested before creating GoogleMap instances, as the renderer can be initialized only once per application context.

AndroidMapRenderer mapRenderer = AndroidMapRenderer.platformDefault;
// ···
  final GoogleMapsFlutterPlatform mapsImplementation =
      GoogleMapsFlutterPlatform.instance;
  if (mapsImplementation is GoogleMapsFlutterAndroid) {
    WidgetsFlutterBinding.ensureInitialized();
    mapRenderer = await mapsImplementation
        .initializeWithRenderer(AndroidMapRenderer.latest);
  }

Available values are AndroidMapRenderer.latest, AndroidMapRenderer.legacy, AndroidMapRenderer.platformDefault. Note that getting the requested renderer as a response is not guaranteed.