maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String topic,
    2. String pairingTopic,
    3. Relay relay,
    4. int expiry,
    5. bool acknowledged,
    6. String controller,
    7. Map<String, Namespace> namespaces,
    8. ConnectionMetadata self,
    9. ConnectionMetadata peer,
    10. Map<String, RequiredNamespace>? requiredNamespaces,
    11. Map<String, RequiredNamespace>? optionalNamespaces,
    12. Map<String, String>? sessionProperties,
    13. List<Cacao>? authentication,
    14. TransportType transportType,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String topic,  String pairingTopic,  Relay relay,  int expiry,  bool acknowledged,  String controller,  Map<String, Namespace> namespaces,  ConnectionMetadata self,  ConnectionMetadata peer,  Map<String, RequiredNamespace>? requiredNamespaces,  Map<String, RequiredNamespace>? optionalNamespaces,  Map<String, String>? sessionProperties,  List<Cacao>? authentication,  TransportType transportType)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SessionData() when $default != null:
return $default(_that.topic,_that.pairingTopic,_that.relay,_that.expiry,_that.acknowledged,_that.controller,_that.namespaces,_that.self,_that.peer,_that.requiredNamespaces,_that.optionalNamespaces,_that.sessionProperties,_that.authentication,_that.transportType);case _:
  return orElse();

}
}