whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- PaymentElementShowTerms? applePay,
- PaymentElementShowTerms? auBecsDebit,
- PaymentElementShowTerms? bancontact,
- PaymentElementShowTerms? card,
- PaymentElementShowTerms? cashApp,
- PaymentElementShowTerms? googlePay,
- PaymentElementShowTerms? ideal,
- PaymentElementShowTerms? payPal,
- PaymentElementShowTerms? sepaDebit,
- PaymentElementShowTerms? sofort,
- PaymentElementShowTerms? usBankAccount,
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( PaymentElementShowTerms? applePay, PaymentElementShowTerms? auBecsDebit, PaymentElementShowTerms? bancontact, PaymentElementShowTerms? card, PaymentElementShowTerms? cashApp, PaymentElementShowTerms? googlePay, PaymentElementShowTerms? ideal, PaymentElementShowTerms? payPal, PaymentElementShowTerms? sepaDebit, PaymentElementShowTerms? sofort, PaymentElementShowTerms? usBankAccount)? $default,) {final _that = this;
switch (_that) {
case _PaymentElementOptionsTerms() when $default != null:
return $default(_that.applePay,_that.auBecsDebit,_that.bancontact,_that.card,_that.cashApp,_that.googlePay,_that.ideal,_that.payPal,_that.sepaDebit,_that.sofort,_that.usBankAccount);case _:
return null;
}
}