when<TResult extends Object?> method
TResult
when<TResult extends Object?>(
- TResult $default(
- @JsonKey.new(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.new(toJson: _cardBrandListToJson) List<
CardBrand> ? preferredNetworks, - CardBrandAcceptance? cardBrandAcceptance,
- bool? opensCardScannerAutomatically,
- required TResult adapter(
- String? setupIntentClientSecret,
- String customerId,
- IntentConfiguration? intentConfiguration,
- String? customerEphemeralKeySecret,
- @JsonKey.new(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.new(toJson: _cardBrandListToJson) List<
CardBrand> ? preferredNetworks, - CardBrandAcceptance? cardBrandAcceptance,
- required TResult session(
- String? setupIntentClientSecret,
- String? customerId,
- IntentConfiguration intentConfiguration,
- String? customerEphemeralKeySecret,
- @JsonKey.new(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.new(toJson: _cardBrandListToJson) List<
CardBrand> ? preferredNetworks, - CardBrandAcceptance? cardBrandAcceptance,
A switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<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,{required 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,required 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():
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():
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():
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 _:
throw StateError('Unexpected subclass');
}
}