withKeyOf method

T withKeyOf(
  1. T model
)

Copy identity (internal key) from an old model to a new one to signal they are the same.

Only makes sense to use if model is immutable and has no ID!

final walter = Person(name: 'Walter');
person.copyWith(age: 56).withKeyOf(walter);

Implementation

T withKeyOf(T model) {
  return DataModel.withKeyOf<T>(source: model, destination: this as T);
}