maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String object,
    3. BankAccountToken? bankAccount,
    4. CardToken? card,
    5. String? clientIP,
    6. int? created,
    7. bool livemode,
    8. TokenType type,
    9. bool used,
    )?, {
  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, @JsonKey(name: "bank_account")  BankAccountToken? bankAccount,  CardToken? card, @JsonKey(name: "client_ip")  String? clientIP,  int? created,  bool livemode,  TokenType type,  bool used)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Token() when $default != null:
return $default(_that.id,_that.object,_that.bankAccount,_that.card,_that.clientIP,_that.created,_that.livemode,_that.type,_that.used);case _:
  return orElse();

}
}