0

我正在尝试通过方法通道进行回调以返回数据(因为我会在另一个函数激活后获取数据),但返回变量已经是回调。我应该怎么办?

Kotlin MethodChannel 代码:

val list: MutableList<String> = ArrayList1()

 override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
         GeneratedPluginRegistrant.registerWith(flutterEngine);
         super.configureFlutterEngine(flutterEngine)

         MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
             .setMethodCallHandler { call: MethodCall, result: Result? ->
                 pendingResult = result
                 if (call.method == "createChannel") {
                  
                     //**my code**
 
                 } else if (call.method == "loginChannel") {
                     if (userLogged == false) {

                         //**this is what I want to put in callback**
                         result?.success(list.toString())
 
                         Toast.makeText(this, list.toString(), Toast.LENGTH_LONG).show()
                     }
                 }
             }
     }
4

0 回答 0