invoke static method

Future invoke(
  1. MethodChannel methodChannel,
  2. dynamic methodName, [
  3. dynamic methodArgs
])

Implementation

static Future<dynamic> invoke(MethodChannel methodChannel, methodName, [dynamic methodArgs]) async {
  try {
    if (methodArgs is Map) {
      var args = methodArgs;
      final result = await methodChannel.invokeMethod(methodName, args);
      return result;
    } else if (methodArgs == null) {
      final result = await methodChannel.invokeMethod(methodName);
      return result;
    }

  } on PlatformException catch (e) {
    debugPrint('$e');
    return null;
  }
}