whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
  1. TResult? $default(
    1. String id,
    2. String certificationId,
    3. String? certificationName,
    4. String userId,
    5. String? userLabel,
    6. DateTime issuedAt,
    7. DateTime? expiresAt,
    8. String status,
    9. Map<String, dynamic> evidence,
    )?
)

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 certificationId,  String? certificationName,  String userId,  String? userLabel,  DateTime issuedAt,  DateTime? expiresAt,  String status,  Map<String, dynamic> evidence)?  $default,) {final _that = this;
switch (_that) {
case _UserCertificate() when $default != null:
return $default(_that.id,_that.certificationId,_that.certificationName,_that.userId,_that.userLabel,_that.issuedAt,_that.expiresAt,_that.status,_that.evidence);case _:
  return null;

}
}