Abu*_*lim 8 google-maps flutter flutter-layout
在启动画面之后,我的应用程序的第一页上有一个谷歌地图。当我第一次运行应用程序和一个非常新的构建时,它在IOS上崩溃并出现此错误:PlatformException(create_failed, can't create a view on a headless engine, null)。
这是我的谷歌地图代码,崩溃仅在安装应用程序时第一次发生在 IOS 中。
GoogleMap(
myLocationEnabled: false,
myLocationButtonEnabled: false,
zoomGesturesEnabled: true,
scrollGesturesEnabled: true,
rotateGesturesEnabled: false,
tiltGesturesEnabled: false,
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _location,
zoom: 12,
/* tilt: 50.0,
bearing: 45.0,*/
),
mapType: _currentMapType,
markers: Set<Marker>.of(markers.values),
onCameraMove: _onCameraMove,
onCameraIdle: _onCameraIdle,
)
Run Code Online (Sandbox Code Playgroud)
我正在 GitHub 上跟进这个问题:https : //github.com/flutter/flutter/issues/36310 但它没有合适的解决方案。任何人都可以帮我解决这个问题吗?
小智 1
您是否已在正确的位置正确注册了 API 密钥?这需要在 flutter 引擎启动之前在appDelegate类中注册。 (请注意,这是一个 swift 文件)
import UIKit
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("super_secret_api_key")
GeneratedPluginRegistrant.register(with: self);
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
978 次 |
| 最近记录: |