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()? invalidPath,
TResult? Function()? noTags,
TResult? Function(String message)? openFile,
TResult? Function(String message)? read,
TResult? Function(String message)? write,
TResult? Function(String message)? remote,
}) {
final _that = this;
switch (_that) {
case HaudiotaggerError_InvalidPath() when invalidPath != null:
return invalidPath();
case HaudiotaggerError_NoTags() when noTags != null:
return noTags();
case HaudiotaggerError_OpenFile() when openFile != null:
return openFile(_that.message);
case HaudiotaggerError_Read() when read != null:
return read(_that.message);
case HaudiotaggerError_Write() when write != null:
return write(_that.message);
case HaudiotaggerError_Remote() when remote != null:
return remote(_that.message);
case _:
return null;
}
}