mapOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? accountHosting(
- USubjectStatusViewHostingAccountHosting value
- TResult? recordHosting(
- USubjectStatusViewHostingRecordHosting value
- TResult? unknown(
- USubjectStatusViewHostingUnknown value
A variant of map
that fallback to returning null
.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( USubjectStatusViewHostingAccountHosting value)? accountHosting,TResult? Function( USubjectStatusViewHostingRecordHosting value)? recordHosting,TResult? Function( USubjectStatusViewHostingUnknown value)? unknown,}){
final _that = this;
switch (_that) {
case USubjectStatusViewHostingAccountHosting() when accountHosting != null:
return accountHosting(_that);case USubjectStatusViewHostingRecordHosting() when recordHosting != null:
return recordHosting(_that);case USubjectStatusViewHostingUnknown() when unknown != null:
return unknown(_that);case _:
return null;
}
}