whenOrNull<TResult extends Object?> method
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 id, String? bookId, String domainId, String? parentTopicId, String title, int depth, int sortOrder, int? pageStart, int? pageEnd, String? curriculumLevelId, @JsonKey(includeFromJson: false, includeToJson: false) List<TopicModel> children)? $default,) {final _that = this;
switch (_that) {
case _TopicModel() when $default != null:
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 _:
return null;
}
}