cancelForKey method Null safety

Future<bool> cancelForKey(
  1. Object key
)

Cancel a StreamSubscription with a specified key and remove it from list

For example:

subxMap.cancelForKey('key');

Implementation

Future<bool> cancelForKey(Object key) async {
  if (_subscriptionMap.containsKey(key)) {
    final subscription = _subscriptionMap.remove(key)!;
    await subscription.cancel();

    return true;
  }

  return false;
}