whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- bool? noKernelTun,
- String secretKey,
- List<
String> ? address, - List<
WireGuardPeerConfig> ? peers, - @JsonKey.new(name: 'mtu') int? mtu,
- List<
int> ? reserved, - XrayTargetStrategy? domainStrategy,
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(
bool? noKernelTun,
String secretKey,
List<String>? address,
List<WireGuardPeerConfig>? peers,
@JsonKey(name: 'mtu') int? mtu,
List<int>? reserved,
XrayTargetStrategy? domainStrategy)?
$default,
) {
final _that = this;
switch (_that) {
case _WireGuardConfig() when $default != null:
return $default(_that.noKernelTun, _that.secretKey, _that.address,
_that.peers, _that.mtu, _that.reserved, _that.domainStrategy);
case _:
return null;
}
}