copyFrom method
Copies compatible fields from any other instance of CrystallisMixin.
Incompatible fields (missing or type-mismatched) are skipped.
Null values are skipped.
Implementation
void copyFrom(CrystallisMixin other) {
// skip this both this and other are of the same type
final bool isSameType = this.runtimeType != other.runtimeType;
for (final name in metadata.keys) {
if (!isSameType) {
final field = metadata[name]!;
final otherMeta = other.metadata[name];
// skip missing or type-mismatched fields
if (otherMeta == null || otherMeta.type != field.type) {
continue;
}
}
final value = other.get(name);
// skip null values
if (value != null) {
set(name, value);
}
}
}