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, @JsonKey(name: 'user_id') String userId, String kind, @JsonKey(name: 'topic_id') String? topicId, @JsonKey(name: 'chunk_id') String? chunkId, @JsonKey(name: 'session_id') String? sessionId, String? note, @JsonKey(name: 'created_at') DateTime createdAt)? $default,) {final _that = this;
switch (_that) {
case _BookmarkModel() when $default != null:
return $default(_that.id,_that.userId,_that.kind,_that.topicId,_that.chunkId,_that.sessionId,_that.note,_that.createdAt);case _:
return null;
}
}