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 cardId, String userId, int quality, String rating, double elapsedDays, int scheduledDays, double? stability, double? difficulty, String? reviewState, DateTime reviewedAt) $default,) {final _that = this;
switch (_that) {
case _ReviewLog():
return $default(_that.id,_that.cardId,_that.userId,_that.quality,_that.rating,_that.elapsedDays,_that.scheduledDays,_that.stability,_that.difficulty,_that.reviewState,_that.reviewedAt);case _:
throw StateError('Unexpected subclass');
}
}