when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- bool? allowInsecure,
- @JsonKey.new(name: 'certificates') List<
TLSCertConfig> ? certs, - String? serverName,
- @JsonKey.new(name: 'alpn') XrayStringList? alpn,
- bool? enableSessionResumption,
- bool? disableSystemRoot,
- String? minVersion,
- String? maxVersion,
- String? cipherSuites,
- String? fingerprint,
- @JsonKey.new(name: 'rejectUnknownSni') bool? rejectUnknownSNI,
- XrayStringList? curvePreferences,
- String? masterKeyLog,
- String? pinnedPeerCertSha256,
- String? verifyPeerCertByName,
- List<
String> ? verifyPeerCertInNames, - String? echServerKeys,
- String? echConfigList,
- ECHForceQuery? echForceQuery,
- @JsonKey.new(name: 'echSockopt') SocketConfig? echSocketSettings,
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( bool? allowInsecure, @JsonKey(name: 'certificates') List<TLSCertConfig>? certs, String? serverName, @JsonKey(name: 'alpn') XrayStringList? alpn, bool? enableSessionResumption, bool? disableSystemRoot, String? minVersion, String? maxVersion, String? cipherSuites, String? fingerprint, @JsonKey(name: 'rejectUnknownSni') bool? rejectUnknownSNI, XrayStringList? curvePreferences, String? masterKeyLog, String? pinnedPeerCertSha256, String? verifyPeerCertByName, List<String>? verifyPeerCertInNames, String? echServerKeys, String? echConfigList, ECHForceQuery? echForceQuery, @JsonKey(name: 'echSockopt') SocketConfig? echSocketSettings) $default,) {final _that = this;
switch (_that) {
case _TLSConfig():
return $default(_that.allowInsecure,_that.certs,_that.serverName,_that.alpn,_that.enableSessionResumption,_that.disableSystemRoot,_that.minVersion,_that.maxVersion,_that.cipherSuites,_that.fingerprint,_that.rejectUnknownSNI,_that.curvePreferences,_that.masterKeyLog,_that.pinnedPeerCertSha256,_that.verifyPeerCertByName,_that.verifyPeerCertInNames,_that.echServerKeys,_that.echConfigList,_that.echForceQuery,_that.echSocketSettings);case _:
throw StateError('Unexpected subclass');
}
}