invokeMethod method

Future<Map<String, dynamic>> invokeMethod(
  1. String method, {
  2. Map<String, dynamic>? arguments,
})

Implementation

Future<Map<String, dynamic>> invokeMethod(String method,
    {Map<String, dynamic>? arguments}) async {
  Log.i(serviceName, 'invoke method: ==$method==');
  if (arguments == null) arguments = {};
  arguments['serviceName'] = serviceName;
  final Map<String, dynamic>? replyMap = await _methodCallHandler
      .invokePlatformMethod(serviceName, method, arguments: arguments);
  if (replyMap == null) {
    Log.i(serviceName, 'invoke method ==$method== return null');
    throw PlatformException(
      code: 'channel-error',
      message: 'Unable to establish connection on channel.',
      details: null,
    );
  } else {
    return replyMap;
  }
}