setupBridge method
bool
setupBridge(
- String channelName,
- dynamic fn(
- dynamic args
)
)
override
Implementation
@override
bool setupBridge(String channelName, dynamic Function(dynamic args) fn) {
// final channelFunctionCallbacks =
// JavascriptRuntime.channelFunctionsRegistered[getEngineInstanceId()];
// if (channelFunctionCallbacks.keys.contains(channelName)) return false;
// channelFunctionCallbacks[channelName] = fn;
_flutterJs.addChannel(channelName, (args) {
final mapArgs = json.decode(args!);
final res = fn(mapArgs);
this.evaluate("""
FLUTTERJS_pendingMessages['${mapArgs['id']}'].resolve(${json.encode(res)});
"""
.trim());
return Future.value(res);
}, dartChannelAddress: 'http://$_dartAddress');
return true;
}