onMethodCall method
Handles method calls from the native platform.
Implementation
Future<dynamic> onMethodCall(final MethodCall call) async {
try {
switch (call.method) {
case 'onPageChanged':
final args = call.arguments as String;
final locatorJson = json.decode(args) as Map<String, dynamic>;
final locator = Locator.fromJson(locatorJson);
R2Log.d('onPageChanged $locator');
if (locator == null) {
R2Log.w('onPageChanged received empty locator');
return null;
}
onPageChanged(locator);
return null;
case 'onExternalLinkActivated':
final link = call.arguments as String;
R2Log.d('onExternalLinkActivated $link');
onExternalLinkActivated?.call(link);
return null;
default:
throw UnimplementedError('Unhandled call ${call.method}');
}
} on Object catch (e) {
R2Log.e(e, data: call.method);
}
}