6

I have searched everywhere for a guide on how to include google maps in flutter desktop application. I tried to follow the iOS guide but didn't work. I did the following in the AppDelegate.swift in the macos/Runnerdirectory

import Cocoa
import FlutterMacOS
import GoogleMaps

@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
  override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
    GMSServices.provideAPIKey("MY_API_KEY")
    return true
  }
}

But I always get the following error

The following build commands failed:
    CompileSwift normal x86_64 /Users/xxxxx/xxxxx/xxxxxx/xxxxx/macos/Runner/AppDelegate.swift
    CompileSwift normal x86_64 /Users/xxxxxxx/xxxxxx/xxxxxx/xxxxxx/macos/Flutter/GeneratedPluginRegistrant.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(3 failures)
Finished with error: Build process failed
evan
  • 5,443
  • 2
  • 11
  • 20

1 Answers1

5

The plugin google_maps_flutter, is only for iOS and Android. It is based on the native SDK for iOS and Android. As far as I know there is no official Google Maps SDK for MacOS, therefore is not posible to implement it inside the flutter plugin.

jamesblasco
  • 1,744
  • 1
  • 9
  • 25
  • 2
    Thank you very much for your response. Can you please give me an idea of how I can implement it though. I'm thinking of webview, does that make sense? – AbdulGafar Olamide Ajao Feb 27 '20 at 10:33
  • 1
    @AbdulGafarAjao It does completely sense, unfortunately native embedded views are not supported yet on MacOS desktop. You are going to have to wait for it. You can subscribe here to follow the request https://github.com/flutter/flutter/issues/41725 – jamesblasco Feb 27 '20 at 14:00
  • Ok, thank you so much @JaimeBlasco... I'm actually working on a school project so I think its best I fully use web mode pending the time that there will be a solution, I'm just bothered about compatibility issues – AbdulGafar Olamide Ajao Feb 28 '20 at 06:10