maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String object,
    3. BillingDetails? billingDetails,
    4. String? customer,
    5. Map<String, dynamic> metadata,
    6. bool livemode,
    7. int? created,
    8. CardPaymentMethod? card,
    9. SepaDebit? sepaDebit,
    10. BacsDebit? bacsDebit,
    11. AuBecsDebit? auBecsDebit,
    12. Ideal? ideal,
    13. Fpx? fpx,
    14. Upi? upi,
    15. UsBankAccount? usBankAccount,
    16. PaymentMethodType type,
    )?, {
  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,  String object,  BillingDetails? billingDetails,  String? customer,  Map<String, dynamic> metadata,  bool livemode,  int? created,  CardPaymentMethod? card,  SepaDebit? sepaDebit,  BacsDebit? bacsDebit,  AuBecsDebit? auBecsDebit,  Ideal? ideal,  Fpx? fpx,  Upi? upi,  UsBankAccount? usBankAccount,  PaymentMethodType type)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PaymentMethod() when $default != null:
return $default(_that.id,_that.object,_that.billingDetails,_that.customer,_that.metadata,_that.livemode,_that.created,_that.card,_that.sepaDebit,_that.bacsDebit,_that.auBecsDebit,_that.ideal,_that.fpx,_that.upi,_that.usBankAccount,_that.type);case _:
  return orElse();

}
}