when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String? id,
    2. String cardId,
    3. String userId,
    4. int quality,
    5. String rating,
    6. double elapsedDays,
    7. int scheduledDays,
    8. double? stability,
    9. double? difficulty,
    10. String? reviewState,
    11. DateTime reviewedAt,
    )
)

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 _ReviewLogModel():
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');

}
}