重复的插件密钥:FLTGoogleMapsPlugin

Nik*_*uru 3 xcode google-maps dart flutter

我正在尝试使用带有颤动的 Google 地图准备一个演示项目,但不知道为什么在控制台中因此错误而崩溃

Runner[39966:208120] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Duplicate plugin key:
FLTGoogleMapsPlugin'
Run Code Online (Sandbox Code Playgroud)

我已经关注了这个链接 flutter-io

提前感谢任何帮助。

Aro*_*ron 8

只是为了澄清评论并提供最终答案 - 您应该小心,[GeneratedPluginRegistrant registerWithRegistry:self]不要在 AppDelegate.m 文件中调用两次。

根据Google Maps Flutter 插件自述文件,您的 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];
}

@end
Run Code Online (Sandbox Code Playgroud)