whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<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,
    )?
)

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,  String orgId,  String name,  String? description,  bool isOnboarding,  String createdBy,  DateTime createdAt,  DateTime updatedAt,  List<LearningPathStepModel>? steps)?  $default,) {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 null;

}
}