whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- XrayNetwork? network,
- XrayAddress? address,
- int? port,
- int? userLevel,
- List<
DNSOutboundRuleConfig> ? rules, - String? nonIPQuery,
- List<
int> ? blockTypes,
A variant of when that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( XrayNetwork? network, XrayAddress? address, int? port, int? userLevel, List<DNSOutboundRuleConfig>? rules, String? nonIPQuery, List<int>? blockTypes)? $default,) {final _that = this;
switch (_that) {
case _DNSOutboundConfig() when $default != null:
return $default(_that.network,_that.address,_that.port,_that.userLevel,_that.rules,_that.nonIPQuery,_that.blockTypes);case _:
return null;
}
}