handleMethodCall method
Handles method calls over the MethodChannel of this plugin. Note: Check the "federated" architecture for a new way of doing this: https://flutter.dev/go/federated-plugins
Implementation
Future<dynamic> handleMethodCall(
MethodCall call, MethodChannel channel) async {
// final MethodChannel channel = MethodChannel('com.wiseminds.mono_flutter', );
switch (call.method) {
case 'setup':
onLoad() {
channel.invokeMethod('onLoad', {});
}
onClose() {
// channel.invokeMethod('onClose', jsonEncode(jsToMap(data)));
}
onEvent(eventName, data) {
// print('$eventName, ${jsonEncode(jsToMap(data))}');
channel.invokeMethod('onEvent',
{'eventName': eventName, 'data': jsonEncode(jsToMap(data))});
}
onSuccess(data) {
channel.invokeMethod('onSuccess', jsonEncode(jsToMap(data)));
}
setProperty(html.window, 'onLoad', allowInterop(onLoad));
setProperty(html.window, 'onClose', allowInterop(onClose));
setProperty(html.window, 'onEvent', allowInterop(onEvent));
setProperty(html.window, 'onSuccess', allowInterop(onSuccess));
setupMonoConnect(
call.arguments['key'] as String,
call.arguments['reference'] as String?,
call.arguments['data'] as String?,
call.arguments['authCode'] as String?,
call.arguments['scope'] as String? ?? "auth");
return;
case 'open':
return open();
default:
throw PlatformException(
code: 'Unimplemented',
details: 'mono_flutter for web doesn\'t implement \'${call.method}\'',
);
}
}