方法:在 Flutter 中释放时,通道不工作

syqv5f0l  于 2023-08-07  发布在  Flutter
关注(0)|答案(1)|浏览(193)
  • MissingPluginException(找不到方法的实现 *

Screenshot(调试时相同的代码工作)

class MainActivity: FlutterActivity() {
    private val channelName = "Toast" ;

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)

        var channel  = MethodChannel(flutterEngine.dartExecutor.binaryMessenger , channelName);

        channel.setMethodCallHandler{call , result-> if(call.method=="showToast"){
           
            Toast.makeText(this , "toast" , Toast.LENGTH_LONG).show()
        } }

    }
}

字符串

pw9qyyiw

pw9qyyiw1#

关闭编辑器上运行的应用,运行此命令Flutter clear,然后运行flutter pub get以再次获取所有依赖项,并在设备上运行应用即可。

相关问题