I'm trying to make callback to return data by method channel (because I will get the data after another function will activate), but returning variable is already callback. What should I do?
Kotlin MethodChannel code:
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()
}
}
}
}