maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String $type,
    2. int id,
    3. int eventId,
    4. @ReportViewStatusConverter() ReportViewStatus status,
    5. @SubjectViewConverter() SubjectView subject,
    6. @ReasonTypeConverter() ReasonType reportType,
    7. String reportedBy,
    8. @SubjectViewConverter() SubjectView reporter,
    9. String? comment,
    10. DateTime createdAt,
    11. DateTime? updatedAt,
    12. DateTime? queuedAt,
    13. List<int>? actionEventIds,
    14. @ModEventViewConverter() List<ModEventView>? actions,
    15. String? actionNote,
    16. @SubjectStatusViewConverter() SubjectStatusView? subjectStatus,
    17. int? relatedReportCount,
    18. @ReportAssignmentConverter() ReportAssignment? assignment,
    19. @QueueViewConverter() QueueView? queue,
    20. bool? isMuted,
    21. 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,  int eventId, @ReportViewStatusConverter()  ReportViewStatus status, @SubjectViewConverter()  SubjectView subject, @ReasonTypeConverter()  ReasonType reportType,  String reportedBy, @SubjectViewConverter()  SubjectView reporter,  String? comment,  DateTime createdAt,  DateTime? updatedAt,  DateTime? queuedAt,  List<int>? actionEventIds, @ModEventViewConverter()  List<ModEventView>? actions,  String? actionNote, @SubjectStatusViewConverter()  SubjectStatusView? subjectStatus,  int? relatedReportCount, @ReportAssignmentConverter()  ReportAssignment? assignment, @QueueViewConverter()  QueueView? queue,  bool? isMuted,  Map<String, dynamic>? $unknown)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ReportView() when $default != null:
return $default(_that.$type,_that.id,_that.eventId,_that.status,_that.subject,_that.reportType,_that.reportedBy,_that.reporter,_that.comment,_that.createdAt,_that.updatedAt,_that.queuedAt,_that.actionEventIds,_that.actions,_that.actionNote,_that.subjectStatus,_that.relatedReportCount,_that.assignment,_that.queue,_that.isMuted,_that.$unknown);case _:
  return orElse();

}
}