maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String userId,
    3. String? domainId,
    4. String title,
    5. String? description,
    6. String targetMastery,
    7. DateTime? targetDate,
    8. String status,
    9. double progressPct,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id,  String userId,  String? domainId,  String title,  String? description,  String targetMastery,  DateTime? targetDate,  String status,  double progressPct)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LearningGoalModel() when $default != null:
return $default(_that.id,_that.userId,_that.domainId,_that.title,_that.description,_that.targetMastery,_that.targetDate,_that.status,_that.progressPct);case _:
  return orElse();

}
}