maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String $type,
    2. int id,
    3. String type,
    4. @ActionViewScopeConverter() ActionViewScope? scope,
    5. @JsonKey.new(toJson: iso8601) DateTime createdAt,
    6. @JsonKey.new(toJson: iso8601) DateTime? reversedAt,
    7. @JsonKey.new(toJson: iso8601) DateTime? expiresAt,
    8. List<String>? labels,
    9. List<String>? policies,
    10. Map<String, dynamic>? $unknown,
    )?, {
  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 $type,  int id,  String type, @ActionViewScopeConverter()  ActionViewScope? scope, @JsonKey(toJson: iso8601)  DateTime createdAt, @JsonKey(toJson: iso8601)  DateTime? reversedAt, @JsonKey(toJson: iso8601)  DateTime? expiresAt,  List<String>? labels,  List<String>? policies,  Map<String, dynamic>? $unknown)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ActionView() when $default != null:
return $default(_that.$type,_that.id,_that.type,_that.scope,_that.createdAt,_that.reversedAt,_that.expiresAt,_that.labels,_that.policies,_that.$unknown);case _:
  return orElse();

}
}