when<TResult extends Object?> method
TResult
when<TResult extends Object?>(
- TResult $default(
- String country,
- String currency,
- PlatformPayWebPaymentItem total,
- List<
PlatformPayWebPaymentItem> displayItems, - bool requestPayerName,
- bool requestPayerEmail,
- bool requestPayerPhone,
- bool requestShipping,
- List<
PlatformPayWebShippingOption> shippingOptions, - List<
PlatformPayWebWalletType> disableWallets,
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( String country, String currency, PlatformPayWebPaymentItem total, List<PlatformPayWebPaymentItem> displayItems, bool requestPayerName, bool requestPayerEmail, bool requestPayerPhone, bool requestShipping, List<PlatformPayWebShippingOption> shippingOptions, List<PlatformPayWebWalletType> disableWallets) $default,) {final _that = this;
switch (_that) {
case _PaymentRequestCreateOptions():
return $default(_that.country,_that.currency,_that.total,_that.displayItems,_that.requestPayerName,_that.requestPayerEmail,_that.requestPayerPhone,_that.requestShipping,_that.shippingOptions,_that.disableWallets);case _:
throw StateError('Unexpected subclass');
}
}