simple_google_maps_flutter 0.0.2 copy "simple_google_maps_flutter: ^0.0.2" to clipboard
simple_google_maps_flutter: ^0.0.2 copied to clipboard

A clone of google_maps_flutter but use simple_platform_view instead of AndroidView for performance optimization

A clone of google_maps_flutter but use simple_platform_view instead of AndroidView for performance optimization

Getting started #

Please check the simple_platform_view package before using this package, as simple_platform_view comes with several drawbacks that need to be considered beforehand.

Usage #

Platform Status
Android
iOS

Add the following dependency to your pubspec.yaml file:

dependencies:
  google_maps_flutter:
  simple_google_maps_flutter:

Android:

Make FlutterView transparent (required)

Add the following code to MainActivity.kt:

  import androidx.annotation.NonNull;
  import io.flutter.embedding.android.FlutterActivity;
  import io.flutter.embedding.android.FlutterActivityLaunchConfigs.BackgroundMode;

  public class MainActivity extends FlutterActivity {

      @NonNull
      @Override
      protected BackgroundMode getBackgroundMode() {
          return BackgroundMode.transparent;
      }
  }

Replace the default GoogleMapsFlutterPlatform.instance with the modified version:

  import 'package:simple_google_maps_flutter/simple_google_maps_flutter.dart';

  @override
  void initState() {
      super.initState();
      if (Platform.isAndroid) {
          SimpleGoogleMapsFlutterAndroid.registerWith();
      }
  }

Other usage is just like google_maps_flutter package

iOS:

Register PlatformViewFactory

Add this to AppDelegate.swift to register PlatformViewFactory to SimplePlatformViewPlugin:

import GoogleMaps
import simple_platform_view;

@objc class AppDelegate: FlutterAppDelegate {
  override func application(
      _ application: UIApplication,
      didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      GMSServices.provideAPIKey("")
      let fakeRegistry = SimplePlatformViewPlugin.createFakeFlutterPluginRegistry(realPluginRegistry: self);
      GeneratedPluginRegistrant.register(with: fakeRegistry);
      return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Replace the default GoogleMapsFlutterPlatform.instance with the modified version:

  import 'package:simple_google_maps_flutter/simple_google_maps_flutter.dart';

  @override
  void initState() {
      super.initState();
      if (Platform.isIOS) {
        SimpleGoogleMapsFlutterIOS.registerWith();
      }
  }
Demo
2
likes
140
pub points
8%
popularity

Publisher

unverified uploader

A clone of google_maps_flutter but use simple_platform_view instead of AndroidView for performance optimization

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, google_maps_flutter_platform_interface, simple_platform_view, stream_transform

More

Packages that depend on simple_google_maps_flutter