whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
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(
int id,
String name,
int suiteID,
List<int> groupIDs,
int? line,
int? column,
String? url,
int? rootLine,
int? rootColumn,
String? rootUrl,
TestMetadata metadata)?
$default,
) {
final _that = this;
switch (_that) {
case _Test() when $default != null:
return $default(
_that.id,
_that.name,
_that.suiteID,
_that.groupIDs,
_that.line,
_that.column,
_that.url,
_that.rootLine,
_that.rootColumn,
_that.rootUrl,
_that.metadata);
case _:
return null;
}
}