whenOrNull<TResult extends Object?> method

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

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 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,) {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 null;

}
}