when<TResult extends Object?> method
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 id, String? bookId, String domainId, String? parentTopicId, String title, int depth, int sortOrder, int? pageStart, int? pageEnd, String? curriculumLevelId, List<Topic> children) $default,) {final _that = this;
switch (_that) {
case _Topic():
return $default(_that.id,_that.bookId,_that.domainId,_that.parentTopicId,_that.title,_that.depth,_that.sortOrder,_that.pageStart,_that.pageEnd,_that.curriculumLevelId,_that.children);case _:
throw StateError('Unexpected subclass');
}
}