handleIncomingCalls static method

Future<void> handleIncomingCalls(
  1. dynamic onCall(
    1. IncomingCall
    )
)

Implementation

static Future<void> handleIncomingCalls(Function(IncomingCall) onCall) async {
  instance._incomingChannel.setMethodCallHandler((call) async {
    if (call.method == 'onEvent') {
      final event = call.arguments['event'];
      switch (event) {
        case "onIncomingCall":
          final callData = jsonDecode(call.arguments['data'].toString()) as Map<String, dynamic>;
          _activeCall = IncomingCall.fromJson(callData);
          onCall.call(_activeCall as IncomingCall);
          break;
        default:
          throw Exception("Unknown call event! ${call.method}");
      }
    }
  });
}