maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String orgId,
    3. String name,
    4. String? description,
    5. bool isOnboarding,
    6. String createdBy,
    7. DateTime createdAt,
    8. DateTime updatedAt,
    9. List<LearningPathStepModel>? steps,
    )?, {
  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 orgId,  String name,  String? description,  bool isOnboarding,  String createdBy,  DateTime createdAt,  DateTime updatedAt,  List<LearningPathStepModel>? steps)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LearningPathModel() when $default != null:
return $default(_that.id,_that.orgId,_that.name,_that.description,_that.isOnboarding,_that.createdBy,_that.createdAt,_that.updatedAt,_that.steps);case _:
  return orElse();

}
}