handleMethod method

  1. @visibleForTesting
Future handleMethod(
  1. MethodCall call
)

Implementation

@visibleForTesting
Future<dynamic> handleMethod(MethodCall call) async {
  Map<String, dynamic> arguments =
      (call.arguments as Map).cast<String, dynamic>();

  switch (call.method) {
    case EVENT_NOTIFICATION_CREATED:
      var received = ReceivedNotification().fromMap(arguments);
      if (createdHandler != null) await createdHandler!(received);
      return;

    case EVENT_NOTIFICATION_DISPLAYED:
      var received = ReceivedNotification().fromMap(arguments);
      if (displayedHandler != null) await displayedHandler!(received);
      return;

    case EVENT_NOTIFICATION_DISMISSED:
      var received = ReceivedAction().fromMap(arguments);
      if (dismissedHandler != null) await dismissedHandler!(received);
      return;

    case EVENT_DEFAULT_ACTION:
      var received = ReceivedAction().fromMap(arguments);
      if (actionHandler != null) await actionHandler!(received);
      return;

    case EVENT_SILENT_ACTION:
      if (arguments[NOTIFICATION_ACTION_TYPE] == _silentBGActionTypeKey) {
        await compute(IsolateController().receiveSilentAction, arguments);
      } else {
        await IsolateController().receiveSilentAction(arguments);
      }
      return;

    default:
      throw UnsupportedError('Unrecognized JSON message');
  }
}