whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- String? referenceId,
- String? invoiceId,
- String? customId,
- String? softDescriptor,
- PPShipping? shipping,
- List<
PPItems> ? items, - PPPayee? payee,
- @JsonKey.new(name: 'amount') PPOrderAmount orderAmount,
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? referenceId,
String? invoiceId,
String? customId,
String? softDescriptor,
PPShipping? shipping,
List<PPItems>? items,
PPPayee? payee,
@JsonKey(name: 'amount') PPOrderAmount orderAmount)?
$default,
) {
final _that = this;
switch (_that) {
case _PPPurchaseUnit() when $default != null:
return $default(
_that.referenceId,
_that.invoiceId,
_that.customId,
_that.softDescriptor,
_that.shipping,
_that.items,
_that.payee,
_that.orderAmount);
case _:
return null;
}
}