package com.atmob.keyboard

import android.app.Application
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.FlutterEngineCache
import io.flutter.embedding.engine.dart.DartExecutor

class AtmobApplication : Application() {

    // 声明一个 FlutterEngine 实例
    lateinit var flutterEngine: FlutterEngine

    override fun onCreate() {
        super.onCreate()

        // 实例化 FlutterEngine，并确保应用退出时，FlutterEngine 能继续运行
        flutterEngine = FlutterEngine(this).apply {
            // 设置 Dart 入口点，确保 Dart 代码能够执行
            dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
        }

        // 将 FlutterEngine 添加到 FlutterEngineCache，使用指定的 engine ID 进行管理
        FlutterEngineCache.getInstance().put("my_engine_id", flutterEngine)
    }
}
