whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- Map<
String, dynamic> ? transport, - Map<
String, String> ? env, - LogConfig? log,
- RouterConfig? routing,
- DNSConfig? dns,
- List<
InboundDetourConfig> ? inbounds, - List<
OutboundDetourConfig> ? outbounds, - PolicyConfig? policy,
- APIConfig? api,
- MetricsConfig? metrics,
- StatsConfig? stats,
- ReverseConfig? reverse,
- @JsonKey.new(name: 'fakeDns') FakeDNSConfig? fakeDns,
- ObservatoryConfig? observatory,
- BurstObservatoryConfig? burstObservatory,
- VersionConfig? version,
- GeodataConfig? geodata,
- Map<
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(
Map<String, dynamic>? transport,
Map<String, String>? env,
LogConfig? log,
RouterConfig? routing,
DNSConfig? dns,
List<InboundDetourConfig>? inbounds,
List<OutboundDetourConfig>? outbounds,
PolicyConfig? policy,
APIConfig? api,
MetricsConfig? metrics,
StatsConfig? stats,
ReverseConfig? reverse,
@JsonKey(name: 'fakeDns') FakeDNSConfig? fakeDns,
ObservatoryConfig? observatory,
BurstObservatoryConfig? burstObservatory,
VersionConfig? version,
GeodataConfig? geodata)?
$default,
) {
final _that = this;
switch (_that) {
case _XrayConfig() when $default != null:
return $default(
_that.transport,
_that.env,
_that.log,
_that.routing,
_that.dns,
_that.inbounds,
_that.outbounds,
_that.policy,
_that.api,
_that.metrics,
_that.stats,
_that.reverse,
_that.fakeDns,
_that.observatory,
_that.burstObservatory,
_that.version,
_that.geodata);
case _:
return null;
}
}