maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String? name,
    3. String userId,
    4. String credentialID,
    5. String publicKey,
    6. @JsonKey.new(fromJson: _counterFromJson) int counter,
    7. String deviceType,
    8. bool backedUp,
    9. String? transports,
    10. DateTime? createdAt,
    11. DateTime? updatedAt,
    12. String? aaguid,
    )?, {
  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? name,  String userId,  String credentialID,  String publicKey, @JsonKey(fromJson: _counterFromJson)  int counter,  String deviceType,  bool backedUp,  String? transports,  DateTime? createdAt,  DateTime? updatedAt,  String? aaguid)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PasskeyRecord() when $default != null:
return $default(_that.id,_that.name,_that.userId,_that.credentialID,_that.publicKey,_that.counter,_that.deviceType,_that.backedUp,_that.transports,_that.createdAt,_that.updatedAt,_that.aaguid);case _:
  return orElse();

}
}