FlutterPlugin 获取上下文
Posted xiangzhihong8
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FlutterPlugin 获取上下文相关的知识,希望对你有一定的参考价值。
在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
以上是关于FlutterPlugin 获取上下文的主要内容,如果未能解决你的问题,请参考以下文章
Flutter实战之FlutterPlugin的应用一步步构建FlutterToast
Flutter实战之FlutterPlugin的应用一步步构建FlutterToast
PluginApplicationException:无法应用插件类“FlutterPlugin”