whenOrNull<TResult extends Object?> method
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 id, String orgId, String invitedUserId, String invitedByUserId, String role, String status, DateTime createdAt, DateTime? resolvedAt, String? orgName, String? inviterName, String? invitedEmail, String? invitedUsername)? $default,) {final _that = this;
switch (_that) {
case _OrgInvitationModel() when $default != null:
return $default(_that.id,_that.orgId,_that.invitedUserId,_that.invitedByUserId,_that.role,_that.status,_that.createdAt,_that.resolvedAt,_that.orgName,_that.inviterName,_that.invitedEmail,_that.invitedUsername);case _:
return null;
}
}