See sample domain model classes with JSON serialization
On this sample PersonCollection
is defined as:
class PersonCollection {
final Iterable<Person> persons;
const PersonCollection({required this.persons});
factory PersonCollection.fromData(DataArray data) => PersonCollection(
persons: data.objects
.map((element) => Person.fromData(element))
.toList(growable: false),
);
DataArray toData() => DataArray.of(
persons.map((person) => person.toData()).toList(growable: false),
);
}
Mapping iterables in both directions in fromData and toData could be easier to implement?
Find choices and add support on DataObject
and/or DataArray
.