maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. bool customFlow,
    2. String? customerId,
    3. String? primaryButtonLabel,
    4. String? customerEphemeralKeySecret,
    5. String? customerSessionClientSecret,
    6. String? paymentIntentClientSecret,
    7. String? setupIntentClientSecret,
    8. IntentConfiguration? intentConfiguration,
    9. String? merchantDisplayName,
    10. PaymentSheetApplePay? applePay,
    11. @JsonKey.new(toJson: UserInterfaceStyleKey.toJson) ThemeMode? style,
    12. PaymentSheetGooglePay? googlePay,
    13. @JsonKey.new(name: 'link') LinkDisplayParams? linkDisplayParams,
    14. bool allowsDelayedPaymentMethods,
    15. PaymentSheetAppearance? appearance,
    16. @JsonKey.new(name: 'defaultBillingDetails') BillingDetails? billingDetails,
    17. bool? allowsRemovalOfLastSavedPaymentMethod,
    18. List<String>? paymentMethodOrder,
    19. String? returnURL,
    20. BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,
    21. String? removeSavedPaymentMethodMessage,
    22. @JsonKey.new(toJson: _cardBrandListToJson) List<CardBrand>? preferredNetworks,
    23. CardBrandAcceptance? cardBrandAcceptance,
    24. CardFundingFiltering? cardFundingFiltering,
    25. CustomPaymentMethodConfiguration? customPaymentMethodConfiguration,
    26. bool? opensCardScannerAutomatically,
    27. @JsonKey.new(toJson: _termsDisplayToJson, fromJson: _termsDisplayFromJson) Map<String, TermsDisplay>? termsDisplay,
    )?, {
  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( bool customFlow,  String? customerId,  String? primaryButtonLabel,  String? customerEphemeralKeySecret,  String? customerSessionClientSecret,  String? paymentIntentClientSecret,  String? setupIntentClientSecret,  IntentConfiguration? intentConfiguration,  String? merchantDisplayName,  PaymentSheetApplePay? applePay, @JsonKey(toJson: UserInterfaceStyleKey.toJson)  ThemeMode? style,  PaymentSheetGooglePay? googlePay, @JsonKey(name: 'link')  LinkDisplayParams? linkDisplayParams,  bool allowsDelayedPaymentMethods,  PaymentSheetAppearance? appearance, @JsonKey(name: 'defaultBillingDetails')  BillingDetails? billingDetails,  bool? allowsRemovalOfLastSavedPaymentMethod,  List<String>? paymentMethodOrder,  String? returnURL,  BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,  String? removeSavedPaymentMethodMessage, @JsonKey(toJson: _cardBrandListToJson)  List<CardBrand>? preferredNetworks,  CardBrandAcceptance? cardBrandAcceptance,  CardFundingFiltering? cardFundingFiltering,  CustomPaymentMethodConfiguration? customPaymentMethodConfiguration,  bool? opensCardScannerAutomatically, @JsonKey(toJson: _termsDisplayToJson, fromJson: _termsDisplayFromJson)  Map<String, TermsDisplay>? termsDisplay)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SetupParameters() when $default != null:
return $default(_that.customFlow,_that.customerId,_that.primaryButtonLabel,_that.customerEphemeralKeySecret,_that.customerSessionClientSecret,_that.paymentIntentClientSecret,_that.setupIntentClientSecret,_that.intentConfiguration,_that.merchantDisplayName,_that.applePay,_that.style,_that.googlePay,_that.linkDisplayParams,_that.allowsDelayedPaymentMethods,_that.appearance,_that.billingDetails,_that.allowsRemovalOfLastSavedPaymentMethod,_that.paymentMethodOrder,_that.returnURL,_that.billingDetailsCollectionConfiguration,_that.removeSavedPaymentMethodMessage,_that.preferredNetworks,_that.cardBrandAcceptance,_that.cardFundingFiltering,_that.customPaymentMethodConfiguration,_that.opensCardScannerAutomatically,_that.termsDisplay);case _:
  return orElse();

}
}