when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- String? masterKeyLog,
- bool? show,
- Object? target,
- Object? dest,
- String? type,
- int? xver,
- List<
String> ? serverNames, - String? privateKey,
- String? minClientVer,
- String? maxClientVer,
- int? maxTimeDiff,
- List<
String> ? shortIds, - String? mldsa65Seed,
- LimitFallback? limitFallbackUpload,
- LimitFallback? limitFallbackDownload,
- String? fingerprint,
- String? serverName,
- String? password,
- String? publicKey,
- String? shortId,
- String? mldsa65Verify,
- String? spiderX,
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? masterKeyLog,
bool? show,
Object? target,
Object? dest,
String? type,
int? xver,
List<String>? serverNames,
String? privateKey,
String? minClientVer,
String? maxClientVer,
int? maxTimeDiff,
List<String>? shortIds,
String? mldsa65Seed,
LimitFallback? limitFallbackUpload,
LimitFallback? limitFallbackDownload,
String? fingerprint,
String? serverName,
String? password,
String? publicKey,
String? shortId,
String? mldsa65Verify,
String? spiderX)
$default,
) {
final _that = this;
switch (_that) {
case _REALITYConfig():
return $default(
_that.masterKeyLog,
_that.show,
_that.target,
_that.dest,
_that.type,
_that.xver,
_that.serverNames,
_that.privateKey,
_that.minClientVer,
_that.maxClientVer,
_that.maxTimeDiff,
_that.shortIds,
_that.mldsa65Seed,
_that.limitFallbackUpload,
_that.limitFallbackDownload,
_that.fingerprint,
_that.serverName,
_that.password,
_that.publicKey,
_that.shortId,
_that.mldsa65Verify,
_that.spiderX);
case _:
throw StateError('Unexpected subclass');
}
}