whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String $type,
    2. int id,
    3. USubjectStatusViewSubject subject,
    4. USubjectStatusViewHosting? hosting,
    5. List<String>? subjectBlobCids,
    6. String? subjectRepoHandle,
    7. DateTime updatedAt,
    8. DateTime createdAt,
    9. SubjectReviewState reviewState,
    10. String? comment,
    11. int? priorityScore,
    12. DateTime? muteUntil,
    13. DateTime? muteReportingUntil,
    14. String? lastReviewedBy,
    15. DateTime? lastReviewedAt,
    16. DateTime? lastReportedAt,
    17. DateTime? lastAppealedAt,
    18. bool? takendown,
    19. bool? appealed,
    20. DateTime? suspendUntil,
    21. List<String>? tags,
    22. AccountStats? accountStats,
    23. RecordsStats? recordsStats,
    24. SubjectStatusViewAgeAssuranceState? ageAssuranceState,
    25. SubjectStatusViewAgeAssuranceUpdatedBy? ageAssuranceUpdatedBy,
    26. Map<String, dynamic>? $unknown,
    )?
)

A variant of when that fallback to returning null

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return null;
}

Implementation

@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String $type,  int id, @USubjectStatusViewSubjectConverter()  USubjectStatusViewSubject subject, @USubjectStatusViewHostingConverter()  USubjectStatusViewHosting? hosting,  List<String>? subjectBlobCids,  String? subjectRepoHandle,  DateTime updatedAt,  DateTime createdAt, @SubjectReviewStateConverter()  SubjectReviewState reviewState,  String? comment,  int? priorityScore,  DateTime? muteUntil,  DateTime? muteReportingUntil,  String? lastReviewedBy,  DateTime? lastReviewedAt,  DateTime? lastReportedAt,  DateTime? lastAppealedAt,  bool? takendown,  bool? appealed,  DateTime? suspendUntil,  List<String>? tags, @AccountStatsConverter()  AccountStats? accountStats, @RecordsStatsConverter()  RecordsStats? recordsStats, @SubjectStatusViewAgeAssuranceStateConverter()  SubjectStatusViewAgeAssuranceState? ageAssuranceState, @SubjectStatusViewAgeAssuranceUpdatedByConverter()  SubjectStatusViewAgeAssuranceUpdatedBy? ageAssuranceUpdatedBy,  Map<String, dynamic>? $unknown)?  $default,) {final _that = this;
switch (_that) {
case _SubjectStatusView() when $default != null:
return $default(_that.$type,_that.id,_that.subject,_that.hosting,_that.subjectBlobCids,_that.subjectRepoHandle,_that.updatedAt,_that.createdAt,_that.reviewState,_that.comment,_that.priorityScore,_that.muteUntil,_that.muteReportingUntil,_that.lastReviewedBy,_that.lastReviewedAt,_that.lastReportedAt,_that.lastAppealedAt,_that.takendown,_that.appealed,_that.suspendUntil,_that.tags,_that.accountStats,_that.recordsStats,_that.ageAssuranceState,_that.ageAssuranceUpdatedBy,_that.$unknown);case _:
  return null;

}
}