whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- String id,
- num amount,
- String created,
- String currency,
- PaymentIntentsStatus status,
- String clientSecret,
- bool livemode,
- CaptureMethod captureMethod,
- ConfirmationMethod confirmationMethod,
- String? paymentMethodId,
- String? description,
- String? receiptEmail,
- String? canceledAt,
- NextAction? nextAction,
- ShippingDetails? shipping,
- MandateData? mandateData,
- String? latestCharge,
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( String id, num amount, String created, String currency, PaymentIntentsStatus status, String clientSecret, bool livemode, CaptureMethod captureMethod, ConfirmationMethod confirmationMethod, String? paymentMethodId, String? description, String? receiptEmail, String? canceledAt, NextAction? nextAction, ShippingDetails? shipping, MandateData? mandateData, String? latestCharge)? $default,) {final _that = this;
switch (_that) {
case _PaymentIntent() when $default != null:
return $default(_that.id,_that.amount,_that.created,_that.currency,_that.status,_that.clientSecret,_that.livemode,_that.captureMethod,_that.confirmationMethod,_that.paymentMethodId,_that.description,_that.receiptEmail,_that.canceledAt,_that.nextAction,_that.shipping,_that.mandateData,_that.latestCharge);case _:
return null;
}
}