when<TResult extends Object?> method

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

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<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,) {final _that = this;
switch (_that) {
case _PasskeyRecord():
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 _:
  throw StateError('Unexpected subclass');

}
}