maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. num amount,
    3. String created,
    4. String currency,
    5. PaymentIntentsStatus status,
    6. String clientSecret,
    7. bool livemode,
    8. CaptureMethod captureMethod,
    9. ConfirmationMethod confirmationMethod,
    10. String? paymentMethodId,
    11. String? description,
    12. String? receiptEmail,
    13. String? canceledAt,
    14. NextAction? nextAction,
    15. ShippingDetails? shipping,
    16. MandateData? mandateData,
    17. String? latestCharge,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id,  num amount,  String created,  String currency,  PaymentIntentsStatus status,  String clientSecret,  bool livemode,  CaptureMethod captureMethod,  ConfirmationMethod confirmationMethod,  String? paymentMethodId,  String? description,  String? receiptEmail,  String? canceledAt,  NextAction? nextAction,  ShippingDetails? shipping,  MandateData? mandateData,  String? latestCharge)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PaymentIntent() when $default != null:
return $default(_that.id,_that.amount,_that.created,_that.currency,_that.status,_that.clientSecret,_that.livemode,_that.captureMethod,_that.confirmationMethod,_that.paymentMethodId,_that.description,_that.receiptEmail,_that.canceledAt,_that.nextAction,_that.shipping,_that.mandateData,_that.latestCharge);case _:
  return orElse();

}
}