maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. Relay relay,
    2. Map<String, Namespace> namespaces,
    3. Map<String, RequiredNamespace>? requiredNamespaces,
    4. Map<String, RequiredNamespace>? optionalNamespaces,
    5. Map<String, String>? sessionProperties,
    6. int expiry,
    7. ConnectionMetadata controller,
    )?, {
  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( Relay relay,  Map<String, Namespace> namespaces,  Map<String, RequiredNamespace>? requiredNamespaces,  Map<String, RequiredNamespace>? optionalNamespaces,  Map<String, String>? sessionProperties,  int expiry,  ConnectionMetadata controller)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _WcSessionSettleRequest() when $default != null:
return $default(_that.relay,_that.namespaces,_that.requiredNamespaces,_that.optionalNamespaces,_that.sessionProperties,_that.expiry,_that.controller);case _:
  return orElse();

}
}