maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String object,
    3. String? application,
    4. String? attachToSelf,
    5. SetupIntentCancellationReason? cancellationReason,
    6. String clientSecret,
    7. int? created,
    8. String? customer,
    9. String? description,
    10. List<SetupIntentFlowDirections>? flowDirections,
    11. dynamic lastSetupError,
    12. String? latestAttempt,
    13. bool livemode,
    14. String? mandate,
    15. Map<String, dynamic> metadata,
    16. dynamic nextAction,
    17. String? onBehalfOf,
    18. String? paymentMethod,
    19. dynamic paymentMethodOptions,
    20. List<PaymentMethodType> paymentMethodTypes,
    21. String? singleUseMandate,
    22. SetupIntentsStatus status,
    23. SetupIntentUsage usage,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id,  String object,  String? application, @JsonKey(name: "attach_to_self")  String? attachToSelf, @JsonKey(name: "cancellation_reason")  SetupIntentCancellationReason? cancellationReason, @JsonKey(name: "client_secret")  String clientSecret,  int? created,  String? customer,  String? description, @JsonKey(name: "flow_directions")  List<SetupIntentFlowDirections>? flowDirections, @JsonKey(name: "last_setup_error")  dynamic lastSetupError, @JsonKey(name: "latest_attempt")  String? latestAttempt,  bool livemode,  String? mandate,  Map<String, dynamic> metadata, @JsonKey(name: "next_action")  dynamic nextAction, @JsonKey(name: "on_behalf_of")  String? onBehalfOf, @JsonKey(name: "payment_method")  String? paymentMethod, @JsonKey(name: "payment_method_options")  dynamic paymentMethodOptions, @JsonKey(name: "payment_method_types")  List<PaymentMethodType> paymentMethodTypes, @JsonKey(name: "single_use_mandate")  String? singleUseMandate,  SetupIntentsStatus status,  SetupIntentUsage usage)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SetupIntent() when $default != null:
return $default(_that.id,_that.object,_that.application,_that.attachToSelf,_that.cancellationReason,_that.clientSecret,_that.created,_that.customer,_that.description,_that.flowDirections,_that.lastSetupError,_that.latestAttempt,_that.livemode,_that.mandate,_that.metadata,_that.nextAction,_that.onBehalfOf,_that.paymentMethod,_that.paymentMethodOptions,_that.paymentMethodTypes,_that.singleUseMandate,_that.status,_that.usage);case _:
  return orElse();

}
}