when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- XrayTargetStrategy? targetStrategy,
- XrayTargetStrategy? domainStrategy,
- String? redirect,
- int? userLevel,
- Fragment? fragment,
- Noise? noise,
- List<
Noise> ? noises, - int? proxyProtocol,
- XrayStringList? ipsBlocked,
- List<
FreedomFinalRuleConfig> ? finalRules,
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(
XrayTargetStrategy? targetStrategy,
XrayTargetStrategy? domainStrategy,
String? redirect,
int? userLevel,
Fragment? fragment,
Noise? noise,
List<Noise>? noises,
int? proxyProtocol,
XrayStringList? ipsBlocked,
List<FreedomFinalRuleConfig>? finalRules)
$default,
) {
final _that = this;
switch (_that) {
case _FreedomConfig():
return $default(
_that.targetStrategy,
_that.domainStrategy,
_that.redirect,
_that.userLevel,
_that.fragment,
_that.noise,
_that.noises,
_that.proxyProtocol,
_that.ipsBlocked,
_that.finalRules);
case _:
throw StateError('Unexpected subclass');
}
}