import 'package:prosapp_web_app/models/region_entity.dart'; class CountryEntity { final String name; final List regions; const CountryEntity({ required this.name, required this.regions, }); Map toDocument() { return { 'name': name, 'states': regions, }; } static CountryEntity fromDocument(Map doc) { return CountryEntity( name: doc['name'] as String, regions: (doc['states'] as List) .map((region) => RegionEntity.fromDocument(region)) .toList(), ); } @override String toString() { return '''CountryEntity { name: $name regions: $regions }'''; } }