Open gavv opened 3 years ago
your field necessarily need both a setter and a getter is you want Floor to be able to use it as a database column.
Here only _field
can be set (via the Constructor) but not field
. So Floor has no way to populate back the field
attribute when a value is read from the database. So you won't be able to use field
as a database column until you also give him a setter.
Floor actually only uses the constructor and not setters(iirc) so this is a reasonable request imho.
If we would want to make these entities immutable, we could take a look at how freezed is doing this? I guess it would change things drastically as we should have a copyWith to update the model when we no longer are able to change the values directly.
Hi! Thanks a lot for this library.
I've the following model class:
It has a private field
_field
with a public getterfield
and no setter.Foo
is immutable: fields are set in constructor and then remain unchanged.If I understand correctly, this use case is not supported by floor currently. Floor generates code that tries to access
_field
and I didn't find a way to tell to usefield
instead.Am I missing something? If not, it would be great if floor allowed working with immutable models somehow.