when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- List<
String> ? types, - String? createdBy,
- String sortDirection,
- DateTime? createdAfter,
- DateTime? createdBefore,
- String? subject,
- List<
String> ? collections, - 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,
- ModerationQueryEventsAgeAssuranceState? ageAssuranceState,
- String? cursor,
- Map<
String, dynamic> ? $unknown,
- List<
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');
}
}