whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- @JsonKey.new(name: 'auth') SocksAuthMethod? authMethod,
- List<
SocksAccount> ? accounts, - bool? udp,
- @JsonKey.new(name: 'ip') XrayAddress? host,
- int? userLevel,
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(@JsonKey(name: 'auth') SocksAuthMethod? authMethod, List<SocksAccount>? accounts, bool? udp, @JsonKey(name: 'ip') XrayAddress? host, int? userLevel)? $default,) {final _that = this;
switch (_that) {
case _SocksServerConfig() when $default != null:
return $default(_that.authMethod,_that.accounts,_that.udp,_that.host,_that.userLevel);case _:
return null;
}
}