[firestore_serialize] getters can't be ignored
Opened this issue · 4 comments
ciriousjoker commented
Example code:
@FirestoreDocument()
class MyModel {
DocumentReference selfRef;
String id;
String label;
MyModel({
this.selfRef,
this.id,
this.label,
});
bool operator ==(o) => o is MyModel && id == o.id;
@override
@FirestoreAttribute(ignore: true)
int get hashCode => id.hashCode;
}
hashCode still makes it into the serialized map :(
Workaround:
Map<String, dynamic> toMap() {
Map ret = _$myModelToMap(this);
ret.remove("hashCode");
return ret;
}
ciriousjoker commented
This seems to be fixed in my fork of it. However, I don't know if this was because of this library or because I updated all the dependencies.
I replaced displayName (deprecated) with element.name, which might differentiate between getters and normal variables automatically.
EDIT: Nevermind, getters are still detected as regular variables, but they only apply to the toMap()
functions
lukas-h commented
Please create a pull request
ciriousjoker commented
Like I said, the test case has been broken by it and this issue is untouched. Should I still make the PR?
lukas-h commented
Yes, we can still work on it the PR until it‘s merged