getNotificationActionStream method

  1. @override
Stream<String> getNotificationActionStream([
  1. dynamic failure(
    1. dynamic p1
    )?
])
override

Android Only The custom notification action button click event stream.

Implementation

@override
Stream<String> getNotificationActionStream([Function(dynamic p1)? failure]) {
  if (_notifyActionStream != null) {
    return _notifyActionStream!;
  }

  var originalStream = _eventChannelNotifyAction
      .receiveBroadcastStream()
      .handleError((dynamic error) {
    if (failure != null) {
      failure(error);
    } else {
      dev.log(
          'NotificationActionStream has error!!!. Uncaught error: $error. You shouid provide a failure callback');
      throw error;
    }
  });

  _notifyActionStream =
      originalStream.asBroadcastStream(onCancel: (controller) {
    controller.cancel();
    _notifyActionStream = null;
  }).map<String>((dynamic e) {
    if (e is String) {
      return e;
    } else {
      return e.toString();
    }
  });

  return _notifyActionStream!;
}