whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- String id,
- String email,
- String currencyCode,
- String customerUrl,
- LineItemsOrder lineItems,
- String name,
- int orderNumber,
- String processedAt,
- ShippingAddress? shippingAddress,
- ShippingAddress? billingAddress,
- String statusUrl,
- PriceV2 subtotalPrice,
- PriceV2 totalPrice,
- PriceV2 totalShippingPrice,
- PriceV2 totalTax,
- String financialStatus,
- String fulfillmentStatus,
- PriceV2? totalRefunded,
- String? phone,
- String? cursor,
- String? canceledAt,
- String? cancelReason,
- List<
SuccessfulFullfilment> ? successfulFulfillments,
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 email, String currencyCode, String customerUrl, LineItemsOrder lineItems, String name, int orderNumber, String processedAt, ShippingAddress? shippingAddress, ShippingAddress? billingAddress, String statusUrl, PriceV2 subtotalPrice, PriceV2 totalPrice, PriceV2 totalShippingPrice, PriceV2 totalTax, String financialStatus, String fulfillmentStatus, PriceV2? totalRefunded, String? phone, String? cursor, String? canceledAt, String? cancelReason, List<SuccessfulFullfilment>? successfulFulfillments)? $default,) {final _that = this;
switch (_that) {
case _Order() when $default != null:
return $default(_that.id,_that.email,_that.currencyCode,_that.customerUrl,_that.lineItems,_that.name,_that.orderNumber,_that.processedAt,_that.shippingAddress,_that.billingAddress,_that.statusUrl,_that.subtotalPrice,_that.totalPrice,_that.totalShippingPrice,_that.totalTax,_that.financialStatus,_that.fulfillmentStatus,_that.totalRefunded,_that.phone,_that.cursor,_that.canceledAt,_that.cancelReason,_that.successfulFulfillments);case _:
return null;
}
}