when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- String? congestion,
- bool? debug,
- String? bbrProfile,
- Bandwidth? brutalUp,
- Bandwidth? brutalDown,
- UdpHop? udpHop,
- int? initStreamReceiveWindow,
- int? maxStreamReceiveWindow,
- int? initConnectionReceiveWindow,
- int? maxConnectionReceiveWindow,
- int? maxIdleTimeout,
- int? keepAlivePeriod,
- bool? disablePathMTUDiscovery,
- int? maxIncomingStreams,
A switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? congestion, bool? debug, String? bbrProfile, Bandwidth? brutalUp, Bandwidth? brutalDown, UdpHop? udpHop, int? initStreamReceiveWindow, int? maxStreamReceiveWindow, int? initConnectionReceiveWindow, int? maxConnectionReceiveWindow, int? maxIdleTimeout, int? keepAlivePeriod, bool? disablePathMTUDiscovery, int? maxIncomingStreams) $default,) {final _that = this;
switch (_that) {
case _QuicParamsConfig():
return $default(_that.congestion,_that.debug,_that.bbrProfile,_that.brutalUp,_that.brutalDown,_that.udpHop,_that.initStreamReceiveWindow,_that.maxStreamReceiveWindow,_that.initConnectionReceiveWindow,_that.maxConnectionReceiveWindow,_that.maxIdleTimeout,_that.keepAlivePeriod,_that.disablePathMTUDiscovery,_that.maxIncomingStreams);case _:
throw StateError('Unexpected subclass');
}
}