when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- String $type,
- int id,
- String name,
- @QueueViewSubjectTypesConverter() List<
QueueViewSubjectTypes> ? subjectTypes, - String? collection,
- List<
String> ? reportTypes, - String? description,
- String createdBy,
- @JsonKey.new(toJson: iso8601) DateTime createdAt,
- @JsonKey.new(toJson: iso8601) DateTime updatedAt,
- bool enabled,
- @JsonKey.new(toJson: iso8601) DateTime? deletedAt,
- @QueueStatsConverter() QueueStats stats,
- 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( String $type, int id, String name, @QueueViewSubjectTypesConverter() List<QueueViewSubjectTypes>? subjectTypes, String? collection, List<String>? reportTypes, String? description, String createdBy, @JsonKey(toJson: iso8601) DateTime createdAt, @JsonKey(toJson: iso8601) DateTime updatedAt, bool enabled, @JsonKey(toJson: iso8601) DateTime? deletedAt, @QueueStatsConverter() QueueStats stats, Map<String, dynamic>? $unknown) $default,) {final _that = this;
switch (_that) {
case _QueueView():
return $default(_that.$type,_that.id,_that.name,_that.subjectTypes,_that.collection,_that.reportTypes,_that.description,_that.createdBy,_that.createdAt,_that.updatedAt,_that.enabled,_that.deletedAt,_that.stats,_that.$unknown);case _:
throw StateError('Unexpected subclass');
}
}