when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. List<String>? types,
    2. String? createdBy,
    3. String sortDirection,
    4. DateTime? createdAfter,
    5. DateTime? createdBefore,
    6. String? subject,
    7. List<String>? collections,
    8. ModerationQueryEventsSubjectType? subjectType,
    9. bool includeAllUserRecords,
    10. int limit,
    11. bool? hasComment,
    12. String? comment,
    13. List<String>? addedLabels,
    14. List<String>? removedLabels,
    15. List<String>? addedTags,
    16. List<String>? removedTags,
    17. List<String>? reportTypes,
    18. List<String>? policies,
    19. List<String>? modTool,
    20. String? batchId,
    21. ModerationQueryEventsAgeAssuranceState? ageAssuranceState,
    22. String? cursor,
    23. Map<String, dynamic>? $unknown,
    )
)

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<String>? types,  String? createdBy,  String sortDirection,  DateTime? createdAfter,  DateTime? createdBefore,  String? subject,  List<String>? collections, @ModerationQueryEventsSubjectTypeConverter()  ModerationQueryEventsSubjectType? subjectType,  bool includeAllUserRecords,  int limit,  bool? hasComment,  String? comment,  List<String>? addedLabels,  List<String>? removedLabels,  List<String>? addedTags,  List<String>? removedTags,  List<String>? reportTypes,  List<String>? policies,  List<String>? modTool,  String? batchId, @ModerationQueryEventsAgeAssuranceStateConverter()  ModerationQueryEventsAgeAssuranceState? ageAssuranceState,  String? cursor,  Map<String, dynamic>? $unknown)  $default,) {final _that = this;
switch (_that) {
case _ModerationQueryEventsInput():
return $default(_that.types,_that.createdBy,_that.sortDirection,_that.createdAfter,_that.createdBefore,_that.subject,_that.collections,_that.subjectType,_that.includeAllUserRecords,_that.limit,_that.hasComment,_that.comment,_that.addedLabels,_that.removedLabels,_that.addedTags,_that.removedTags,_that.reportTypes,_that.policies,_that.modTool,_that.batchId,_that.ageAssuranceState,_that.cursor,_that.$unknown);case _:
  throw StateError('Unexpected subclass');

}
}