maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- 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,
- 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();
}
}