whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- DateTime? startDate,
- DateTime? endDate,
- String? timezone,
- int? groupId,
- String? model,
- Sub2ApiAdminModelSource modelSource,
- String? endpoint,
- Sub2ApiAdminEndpointType endpointType,
- int? userId,
- int? apiKeyId,
- int? accountId,
- Sub2ApiAdminUsageRequestType? requestType,
- bool? stream,
- Sub2ApiAdminBillingType? billingType,
- Sub2ApiAdminUserBreakdownSort? sortBy,
- int limit,
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(
DateTime? startDate,
DateTime? endDate,
String? timezone,
int? groupId,
String? model,
Sub2ApiAdminModelSource modelSource,
String? endpoint,
Sub2ApiAdminEndpointType endpointType,
int? userId,
int? apiKeyId,
int? accountId,
Sub2ApiAdminUsageRequestType? requestType,
bool? stream,
Sub2ApiAdminBillingType? billingType,
Sub2ApiAdminUserBreakdownSort? sortBy,
int limit,
)?
$default,
) {
final _that = this;
switch (_that) {
case _Sub2ApiAdminUserBreakdownQuery() when $default != null:
return $default(
_that.startDate,
_that.endDate,
_that.timezone,
_that.groupId,
_that.model,
_that.modelSource,
_that.endpoint,
_that.endpointType,
_that.userId,
_that.apiKeyId,
_that.accountId,
_that.requestType,
_that.stream,
_that.billingType,
_that.sortBy,
_that.limit,
);
case _:
return null;
}
}