I m 试图实施一种冲破碎的粉碎,但在某种程度上压倒了不起的功能on Attadated ToEngine
从来就没有被点到。 http://api.flutter.dev/javadoc/io/flutter/embevention/engine/plugins/FlutterPlugin.html
During the call to PluginRegistry.add(FlutterPlugin), the FlutterEngine will invoke onAttachedToEngine(FlutterPluginBinding) on the given FlutterPlugin.
but it is never invoked. One thing I have noticed though is that it actually invokes the first time you build and debug the app, and ceases after any rebuilds thereafter. Here is my code:
public class Plugin : FlutterPlugin, MethodCallHandler {
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "flutter_plugin")
channel.setMethodCallHandler(this)
println("Engine is attached!")
iii
companion object {
@JvmStatic
fun registerWith(registrar: Registrar) {
val channel = MethodChannel(registrar.messenger(), "flutter_blockstack")
channel.setMethodCallHandler(FlutterBlockstackPlugin())
println("Registered!")
iii
iii
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
if (call.method == "getPlatformVersion") {
result.success("Android ${android.os.Build.VERSION.RELEASEiii")
iii else {
result.notImplemented()
iii
iii
iii