maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String object,
    3. int amount,
    4. int? amountCapturable,
    5. PaymentIntentAmountDetails? amountDetails,
    6. int? amountReceived,
    7. String? application,
    8. int? applicationFeeAmount,
    9. PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods,
    10. int? canceledAt,
    11. PaymentIntentCancellationReason? cancellationReason,
    12. String clientSecret,
    13. PaymentIntentCaptureMethod captureMethod,
    14. PaymentIntentConfirmationMethod confirmationMethod,
    15. int? created,
    16. String currency,
    17. String? customer,
    18. String? description,
    19. String? invoice,
    20. StripeError? lastPaymentError,
    21. String? latestCharge,
    22. bool livemode,
    23. Map<String, dynamic> metadata,
    24. dynamic nextAction,
    25. String? onBehalfOf,
    26. String? paymentMethod,
    27. Map paymentMethodOptions,
    28. List<PaymentMethodType> paymentMethodTypes,
    29. dynamic processing,
    30. String? receiptEmail,
    31. String? review,
    32. PaymentIntentSetupFutureUsage? setupFutureUsage,
    33. ShippingDetails? shipping,
    34. String? statementDescriptor,
    35. String? statementDescriptorSuffix,
    36. PaymentIntentsStatus status,
    37. dynamic transferData,
    38. dynamic transferGroup,
    )?, {
  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,  int amount, @JsonKey(name: "amount_capturable")  int? amountCapturable, @JsonKey(name: "amount_details")  PaymentIntentAmountDetails? amountDetails, @JsonKey(name: "amount_received")  int? amountReceived,  String? application, @JsonKey(name: "application_fee_amount")  int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods")  PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, @JsonKey(name: "canceled_at")  int? canceledAt, @JsonKey(name: "cancellation_reason")  PaymentIntentCancellationReason? cancellationReason, @JsonKey(name: "client_secret")  String clientSecret, @JsonKey(name: "capture_method")  PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method")  PaymentIntentConfirmationMethod confirmationMethod,  int? created,  String currency,  String? customer,  String? description,  String? invoice, @JsonKey(name: "last_payment_error")  StripeError? lastPaymentError, @JsonKey(name: "latest_charge")  String? latestCharge,  bool livemode,  Map<String, dynamic> metadata, @JsonKey(name: "next_action")  dynamic nextAction, @JsonKey(name: "on_behalf_of")  String? onBehalfOf, @JsonKey(name: "payment_method")  String? paymentMethod, @JsonKey(name: "payment_method_options")  Map<dynamic, dynamic> paymentMethodOptions, @JsonKey(name: "payment_method_types", unknownEnumValue: PaymentMethodType.unknown)  List<PaymentMethodType> paymentMethodTypes,  dynamic processing, @JsonKey(name: "receipt_email")  String? receiptEmail,  String? review, @JsonKey(name: "setup_future_usage")  PaymentIntentSetupFutureUsage? setupFutureUsage,  ShippingDetails? shipping, @JsonKey(name: "statement_descriptor")  String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix")  String? statementDescriptorSuffix,  PaymentIntentsStatus status, @JsonKey(name: "transfer_data")  dynamic transferData, @JsonKey(name: "transfer_group")  dynamic transferGroup)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PaymentIntent() when $default != null:
return $default(_that.id,_that.object,_that.amount,_that.amountCapturable,_that.amountDetails,_that.amountReceived,_that.application,_that.applicationFeeAmount,_that.automaticPaymentMethods,_that.canceledAt,_that.cancellationReason,_that.clientSecret,_that.captureMethod,_that.confirmationMethod,_that.created,_that.currency,_that.customer,_that.description,_that.invoice,_that.lastPaymentError,_that.latestCharge,_that.livemode,_that.metadata,_that.nextAction,_that.onBehalfOf,_that.paymentMethod,_that.paymentMethodOptions,_that.paymentMethodTypes,_that.processing,_that.receiptEmail,_that.review,_that.setupFutureUsage,_that.shipping,_that.statementDescriptor,_that.statementDescriptorSuffix,_that.status,_that.transferData,_that.transferGroup);case _:
  return orElse();

}
}