whenOrNull<TResult extends Object?> method
- TResult? $default()?
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? targetUserId, String? targetOrgId, GrantType grantType, PlanTier? plan, int? discountPct, int? aiBoostMessages, int? trialExtensionDays, DateTime startsAt, DateTime? endsAt, String? reason, String? grantedBy, DateTime createdAt, DateTime? revokedAt, String? revokedBy)? $default,) {final _that = this;
switch (_that) {
case _AdminGrant() when $default != null:
return $default(_that.id,_that.targetUserId,_that.targetOrgId,_that.grantType,_that.plan,_that.discountPct,_that.aiBoostMessages,_that.trialExtensionDays,_that.startsAt,_that.endsAt,_that.reason,_that.grantedBy,_that.createdAt,_that.revokedAt,_that.revokedBy);case _:
return null;
}
}