maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String $type,
    2. String source,
    3. int id,
    4. @JsonKey.new(toJson: iso8601) DateTime createdAt,
    5. String createdBy,
    6. String type,
    7. String? subject,
    8. int? reportId,
    9. int? actionEventId,
    10. @ModEventViewConverter() ModEventView? event,
    11. @ReportActivityViewConverter() ReportActivityView? activity,
    12. 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,  String source,  int id, @JsonKey(toJson: iso8601)  DateTime createdAt,  String createdBy,  String type,  String? subject,  int? reportId,  int? actionEventId, @ModEventViewConverter()  ModEventView? event, @ReportActivityViewConverter()  ReportActivityView? activity,  Map<String, dynamic>? $unknown)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ActivityRow() when $default != null:
return $default(_that.$type,_that.source,_that.id,_that.createdAt,_that.createdBy,_that.type,_that.subject,_that.reportId,_that.actionEventId,_that.event,_that.activity,_that.$unknown);case _:
  return orElse();

}
}