whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String tenant,
    2. String apiKey,
    3. String apiUrl,
    4. List<String> spkiPins,
    5. int timeoutMs,
    6. int queueProcessIntervalMs,
    7. bool enableLogging,
    8. bool unsafeMode,
    )?
)

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( String tenant,  String apiKey,  String apiUrl,  List<String> spkiPins,  int timeoutMs,  int queueProcessIntervalMs,  bool enableLogging,  bool unsafeMode)?  $default,) {final _that = this;
switch (_that) {
case _TrackerConfiguration() when $default != null:
return $default(_that.tenant,_that.apiKey,_that.apiUrl,_that.spkiPins,_that.timeoutMs,_that.queueProcessIntervalMs,_that.enableLogging,_that.unsafeMode);case _:
  return null;

}
}