Senior Software Engineer @ Originate
// CLIENT CODE
static const platform = const MethodChannel('org.ocandroid.channel');
// invokeMethod returns Future
await platform.invokeMethod('someMethod');
// ANDROID CODE
MethodChannel(flutterView, "org.ocandroid.channel")
.setMethodCallHandler { call, result -> {
if (call.method == "someMethod") {
if (someCondition) {
result.success(someValue)
} else {
result.error("errCode", "errMessage", errDataObj)
}
} else {
result.notImplemented()
}
}