Alternative Flutter method channel.
Decode method channel's result in different Isolate (based on package 'dart-executor'), alternative for MethodChannel
which using JSONMethodCodec
.
Alternative for MethodChannel
which using StandardMethodCodec
.
Add dependency in pubspec.yaml
:
dependencies:
method_channel_ex:
git: https://github.com/yrom/flutter_method_channel_ex.git
In flutter:
import 'package:method_channel_ex/method_channel_ex.dart';
var channel = FatJsonMethodChannel("test");
var json = channel.invokeMethod("getAFatJson");
In native (e.g. Android):
MethodChannel(
flutterView,
"test",
JSONMethodCodec.INSTANCE
).setMethodCallHandler { methodCall, result ->
if (methodCall.method == "getAFatJson") {
val json = JSONObject()
for (i in 1..1000) {
json.put("$i", "abc".repeat(i % 10))
}
result.success(json)
} else {
result.notImplemented()
}
}