在Flutter插件开发过程中,有时候需要在FlutterPlugin中获取上下文信息,那可以使用FlutterPluginBinding来获取,代码如下:
package com.anguomob.flutter_plugin_anguo
import android.app.Activity
import android.content.Context
import androidx.annotation.NonNull
import com.anguomob.flutter_plugin_anguo.utils.AppUtils
import com.anguomob.flutter_plugin_anguo.utils.FlutterUtils
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.Registrar
/** FlutterPluginAnguoPlugin */
class FlutterPluginAnguoPlugin: FlutterPlugin, MethodCallHandler, ActivityAware {
/// The MethodChannel that will the comm
本文同步分享在 博客“xiangzhihong8”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。