【发布时间】:2020-05-10 06:38:23
【问题描述】:
我在创建flutter插件时,插件类默认有两个方法:
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding)
和
fun registerWith(registrar: Registrar)
文件上的评论说:
It is encouraged to share logic between onAttachedToEngine and registerWith to keep them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called depending on the user's project. onAttachedToEngine or registerWith must both be defined in the same class.
现在,我需要从这里开始另一个活动,activity.startActivityForResult()。
可以使用registrar.activity() 获得对registerWith(registrar: Registrar) 中活动的引用。如何在方法onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) 中做到这一点?
【问题讨论】:
标签: flutter flutter-plugin flutter-platform-channel