when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- int? mark,
- Object? tcpFastOpen,
- TProxyMode? tproxy,
- bool? acceptProxyProtocol,
- XrayTargetStrategy? domainStrategy,
- String? dialerProxy,
- int? tcpKeepAliveInterval,
- int? tcpKeepAliveIdle,
- String? tcpCongestion,
- int? tcpWindowClamp,
- int? tcpMaxSeg,
- bool? penetrate,
- int? tcpUserTimeout,
- bool? v6only,
- @JsonKey.new(name: 'interface') String? interfaceName,
- bool? tcpMptcp,
- List<
CustomSockoptConfig> ? customSockopt, - AddressPortStrategy? addressPortStrategy,
- HappyEyeballsConfig? happyEyeballs,
- List<
String> ? trustedXForwardedFor,
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( int? mark, Object? tcpFastOpen, TProxyMode? tproxy, bool? acceptProxyProtocol, XrayTargetStrategy? domainStrategy, String? dialerProxy, int? tcpKeepAliveInterval, int? tcpKeepAliveIdle, String? tcpCongestion, int? tcpWindowClamp, int? tcpMaxSeg, bool? penetrate, int? tcpUserTimeout, bool? v6only, @JsonKey(name: 'interface') String? interfaceName, bool? tcpMptcp, List<CustomSockoptConfig>? customSockopt, AddressPortStrategy? addressPortStrategy, HappyEyeballsConfig? happyEyeballs, List<String>? trustedXForwardedFor) $default,) {final _that = this;
switch (_that) {
case _SocketConfig():
return $default(_that.mark,_that.tcpFastOpen,_that.tproxy,_that.acceptProxyProtocol,_that.domainStrategy,_that.dialerProxy,_that.tcpKeepAliveInterval,_that.tcpKeepAliveIdle,_that.tcpCongestion,_that.tcpWindowClamp,_that.tcpMaxSeg,_that.penetrate,_that.tcpUserTimeout,_that.v6only,_that.interfaceName,_that.tcpMptcp,_that.customSockopt,_that.addressPortStrategy,_that.happyEyeballs,_that.trustedXForwardedFor);case _:
throw StateError('Unexpected subclass');
}
}