English 中文(简体)
图Engine的超负荷方法从来都不会被挥霍于卢布普金。
原标题:Override method onAttachedToEngine never gets called in FlutterPlugin

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

最佳回答

这是预期的行为。

这项职能在附属于“FlutterEngine”之后,就要求设立一个新的<代码>。 方法CallHandler。 页: 1 Attadated ToEngine (AndroidX) or in registerWith (non-X)。

The function that actually gets called more than once is the onMethodCall, that gets called anytime you want from flutter with invokeMethod.

热重新启动或热后重载不会触发<>Attabed ToEngine,因为实际上,你从发动机中脱下了车,因此,你需要打碎和停机,才能启动。

我希望这一澄清能够帮助你们!

问题回答

就我的情况而言,在Logcat上只显示 log的 log子。 由于我对花.的原木,例如,许多itter子隐藏着它。 但是,Logcat显示了所有这些。 因此,我检查了Logcat的原始木料。 希望这一信息能够帮助我的某个人。

创造出你需要使用突击性制造的gin子——template=plugin

Use the --platforms option to specify which languages ​​the plugin will be available in. There are options like: android, ios, web, linux, macos, windows Use the --org option to specify the domain name for your organization Use the --a option to specify the language for android. You can choose java or kotlin Use the --i option to specify the language for ios. You can choose swift or objc And the last will be your plugin name

参考:

页: 1 - 快速抽样——普卢宁-弗特





相关问题
Exposed runs query on all HikariCP open connections

I m running a Ktor server with a PostgreSQL database and just set up the JetBrains Exposed ORM framework with HikariCP for connection pooling (per the recommendation in the Ktor documentation). My ...

SQLite Kotlin issue - no database

I am trying to create boardgamegeek APIs based app in AndroidStudio, however from unknown reason I m getting my database created with no columns. Here s Logical log: (1) no such table: games in "...

Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

热门标签