whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- Sub2ApiAdminQuotaPlatform platform,
- Sub2ApiDecimal dailyUsageUsd,
- Sub2ApiDecimal? dailyLimitUsd,
- DateTime? dailyWindowResetsAt,
- DateTime? dailyWindowStart,
- Sub2ApiDecimal weeklyUsageUsd,
- Sub2ApiDecimal? weeklyLimitUsd,
- DateTime? weeklyWindowResetsAt,
- DateTime? weeklyWindowStart,
- Sub2ApiDecimal monthlyUsageUsd,
- Sub2ApiDecimal? monthlyLimitUsd,
- DateTime? monthlyWindowResetsAt,
- DateTime? monthlyWindowStart,
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(
Sub2ApiAdminQuotaPlatform platform,
Sub2ApiDecimal dailyUsageUsd,
Sub2ApiDecimal? dailyLimitUsd,
DateTime? dailyWindowResetsAt,
DateTime? dailyWindowStart,
Sub2ApiDecimal weeklyUsageUsd,
Sub2ApiDecimal? weeklyLimitUsd,
DateTime? weeklyWindowResetsAt,
DateTime? weeklyWindowStart,
Sub2ApiDecimal monthlyUsageUsd,
Sub2ApiDecimal? monthlyLimitUsd,
DateTime? monthlyWindowResetsAt,
DateTime? monthlyWindowStart,
)?
$default,
) {
final _that = this;
switch (_that) {
case _Sub2ApiAdminUserPlatformQuota() when $default != null:
return $default(
_that.platform,
_that.dailyUsageUsd,
_that.dailyLimitUsd,
_that.dailyWindowResetsAt,
_that.dailyWindowStart,
_that.weeklyUsageUsd,
_that.weeklyLimitUsd,
_that.weeklyWindowResetsAt,
_that.weeklyWindowStart,
_that.monthlyUsageUsd,
_that.monthlyLimitUsd,
_that.monthlyWindowResetsAt,
_that.monthlyWindowStart,
);
case _:
return null;
}
}