I have a Custom Object Wishlist
which I am serializing
and saving/retrieving as JSON
from Firebase
.
@JsonSerializable()
class Wishlist {
final String id;
String name;
List<Wish>? wishes;
Wishlist({
required this.id,
required this.name,
this.wishes,
});
factory Wishlist.fromJson(Map<String, dynamic> json) =>
_$WishlistFromJson(json);
Map<String, dynamic> toJson() => _$WishlistToJson(this);
}
The thing is that I want wishes
not to be saved as a documentField
but as a subCollection
.
How can I achieve that? Right now there is always a field wishes
which is null
. And then I save wishes
in a subcollection
. But that does not seem ideal.
How can I fix that? Let me know if you need any more info!