maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String domain,
    2. String uri,
    3. CacaoHeader? type,
    4. String? nbf,
    5. String? exp,
    6. String? statement,
    7. String? requestId,
    8. List<String>? resources,
    9. int? expiry,
    10. String? iat,
    11. List<String>? methods,
    )?, {
  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 domain,  String uri,  CacaoHeader? type,  String? nbf,  String? exp,  String? statement,  String? requestId,  List<String>? resources,  int? expiry,  String? iat,  List<String>? methods)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SIWEMessageArgs() when $default != null:
return $default(_that.domain,_that.uri,_that.type,_that.nbf,_that.exp,_that.statement,_that.requestId,_that.resources,_that.expiry,_that.iat,_that.methods);case _:
  return orElse();

}
}