whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String paymentDescription,
    2. String managementUrl,
    3. String? billingAgreement,
    4. DateTime? freeCancellationDate,
    5. String? freeCancellationTimezone,
    6. PaymentElementApplePayDeferredPaymentProperties deferredBilling,
    )?
)

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 paymentDescription,  String managementUrl,  String? billingAgreement,  DateTime? freeCancellationDate,  String? freeCancellationTimezone,  PaymentElementApplePayDeferredPaymentProperties deferredBilling)?  $default,) {final _that = this;
switch (_that) {
case _PaymentElementApplePayDeferredPaymentRequest() when $default != null:
return $default(_that.paymentDescription,_that.managementUrl,_that.billingAgreement,_that.freeCancellationDate,_that.freeCancellationTimezone,_that.deferredBilling);case _:
  return null;

}
}