import Flutter
import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate {
  private var coreApi: CoreApiImpl?
  
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let controller = window?.rootViewController as! FlutterViewController
    
    // 创建 CoreApi 实例
    coreApi = CoreApiImpl(controller: controller)
    
    // 注册 CoreApi
    CoreApiSetup.setUp(binaryMessenger: controller.binaryMessenger, api: coreApi)
    
    GeneratedPluginRegistrant.register(with: self)
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
