whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. @JsonKey.new(toJson: UserInterfaceStyleKey.toJson) ThemeMode? style,
    2. PaymentSheetAppearance? appearance,
    3. String? setupIntentClientSecret,
    4. String customerId,
    5. String customerEphemeralKeySecret,
    6. String? merchantDisplayName,
    7. bool? allowsRemovalOfLastSavedPaymentMethod,
    8. String? headerTextForSelectionScreen,
    9. BillingDetails? defaultBillingDetails,
    10. BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,
    11. String? returnURL,
    12. String? removeSavedPaymentMethodMessage,
    13. bool applePayEnabled,
    14. bool googlePayEnabled,
    15. @JsonKey.new(toJson: _cardBrandListToJson) List<CardBrand>? preferredNetworks,
    16. CardBrandAcceptance? cardBrandAcceptance,
    17. bool? opensCardScannerAutomatically,
    )?, {
  2. TResult? adapter(
    1. String? setupIntentClientSecret,
    2. String customerId,
    3. IntentConfiguration? intentConfiguration,
    4. String? customerEphemeralKeySecret,
    5. @JsonKey.new(toJson: UserInterfaceStyleKey.toJson) ThemeMode? style,
    6. PaymentSheetAppearance? appearance,
    7. String? merchantDisplayName,
    8. bool? allowsRemovalOfLastSavedPaymentMethod,
    9. String? headerTextForSelectionScreen,
    10. BillingDetails? defaultBillingDetails,
    11. BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,
    12. String? returnURL,
    13. String? removeSavedPaymentMethodMessage,
    14. bool applePayEnabled,
    15. bool googlePayEnabled,
    16. @JsonKey.new(toJson: _cardBrandListToJson) List<CardBrand>? preferredNetworks,
    17. CardBrandAcceptance? cardBrandAcceptance,
    )?,
  3. TResult? session(
    1. String? setupIntentClientSecret,
    2. String? customerId,
    3. IntentConfiguration intentConfiguration,
    4. String? customerEphemeralKeySecret,
    5. @JsonKey.new(toJson: UserInterfaceStyleKey.toJson) ThemeMode? style,
    6. PaymentSheetAppearance? appearance,
    7. String? merchantDisplayName,
    8. bool? allowsRemovalOfLastSavedPaymentMethod,
    9. String? headerTextForSelectionScreen,
    10. BillingDetails? defaultBillingDetails,
    11. BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,
    12. String? returnURL,
    13. String? removeSavedPaymentMethodMessage,
    14. bool applePayEnabled,
    15. bool googlePayEnabled,
    16. @JsonKey.new(toJson: _cardBrandListToJson) List<CardBrand>? preferredNetworks,
    17. CardBrandAcceptance? cardBrandAcceptance,
    )?,
})

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(@JsonKey(toJson: UserInterfaceStyleKey.toJson)  ThemeMode? style,  PaymentSheetAppearance? appearance,  String? setupIntentClientSecret,  String customerId,  String customerEphemeralKeySecret,  String? merchantDisplayName,  bool? allowsRemovalOfLastSavedPaymentMethod,  String? headerTextForSelectionScreen,  BillingDetails? defaultBillingDetails,  BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,  String? returnURL,  String? removeSavedPaymentMethodMessage,  bool applePayEnabled,  bool googlePayEnabled, @JsonKey(toJson: _cardBrandListToJson)  List<CardBrand>? preferredNetworks,  CardBrandAcceptance? cardBrandAcceptance,  bool? opensCardScannerAutomatically)?  $default,{TResult? Function( String? setupIntentClientSecret,  String customerId,  IntentConfiguration? intentConfiguration,  String? customerEphemeralKeySecret, @JsonKey(toJson: UserInterfaceStyleKey.toJson)  ThemeMode? style,  PaymentSheetAppearance? appearance,  String? merchantDisplayName,  bool? allowsRemovalOfLastSavedPaymentMethod,  String? headerTextForSelectionScreen,  BillingDetails? defaultBillingDetails,  BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,  String? returnURL,  String? removeSavedPaymentMethodMessage,  bool applePayEnabled,  bool googlePayEnabled, @JsonKey(toJson: _cardBrandListToJson)  List<CardBrand>? preferredNetworks,  CardBrandAcceptance? cardBrandAcceptance)?  adapter,TResult? Function( String? setupIntentClientSecret,  String? customerId,  IntentConfiguration intentConfiguration,  String? customerEphemeralKeySecret, @JsonKey(toJson: UserInterfaceStyleKey.toJson)  ThemeMode? style,  PaymentSheetAppearance? appearance,  String? merchantDisplayName,  bool? allowsRemovalOfLastSavedPaymentMethod,  String? headerTextForSelectionScreen,  BillingDetails? defaultBillingDetails,  BillingDetailsCollectionConfiguration? billingDetailsCollectionConfiguration,  String? returnURL,  String? removeSavedPaymentMethodMessage,  bool applePayEnabled,  bool googlePayEnabled, @JsonKey(toJson: _cardBrandListToJson)  List<CardBrand>? preferredNetworks,  CardBrandAcceptance? cardBrandAcceptance)?  session,}) {final _that = this;
switch (_that) {
case _CustomerSheetInitParamsDeprecated() when $default != null:
return $default(_that.style,_that.appearance,_that.setupIntentClientSecret,_that.customerId,_that.customerEphemeralKeySecret,_that.merchantDisplayName,_that.allowsRemovalOfLastSavedPaymentMethod,_that.headerTextForSelectionScreen,_that.defaultBillingDetails,_that.billingDetailsCollectionConfiguration,_that.returnURL,_that.removeSavedPaymentMethodMessage,_that.applePayEnabled,_that.googlePayEnabled,_that.preferredNetworks,_that.cardBrandAcceptance,_that.opensCardScannerAutomatically);case _CustomerSheetInitParamsAdapter() when adapter != null:
return adapter(_that.setupIntentClientSecret,_that.customerId,_that.intentConfiguration,_that.customerEphemeralKeySecret,_that.style,_that.appearance,_that.merchantDisplayName,_that.allowsRemovalOfLastSavedPaymentMethod,_that.headerTextForSelectionScreen,_that.defaultBillingDetails,_that.billingDetailsCollectionConfiguration,_that.returnURL,_that.removeSavedPaymentMethodMessage,_that.applePayEnabled,_that.googlePayEnabled,_that.preferredNetworks,_that.cardBrandAcceptance);case _CustomerSheetInitParamsSession() when session != null:
return session(_that.setupIntentClientSecret,_that.customerId,_that.intentConfiguration,_that.customerEphemeralKeySecret,_that.style,_that.appearance,_that.merchantDisplayName,_that.allowsRemovalOfLastSavedPaymentMethod,_that.headerTextForSelectionScreen,_that.defaultBillingDetails,_that.billingDetailsCollectionConfiguration,_that.returnURL,_that.removeSavedPaymentMethodMessage,_that.applePayEnabled,_that.googlePayEnabled,_that.preferredNetworks,_that.cardBrandAcceptance);case _:
  return null;

}
}