class UserAddress { final int? id; final String name; final String position; final String tag; final DateTime? timestmp; UserAddress({ this.id, required this.name, required this.position, required this.tag, this.timestmp, }); factory UserAddress.fromJson(Map json) { return UserAddress( id: json['id'], name: json['name']??"Position not recognized", tag: json['tag'], position: json['position'], timestmp: (json['timestmp'] ?? json['timestmp']) != null ? DateTime.fromMillisecondsSinceEpoch( json['timestmp'] ?? json['timestmp']) : DateTime.now(), ); } Map toJson() { return { 'name': name, 'position': position, 'tag': tag, }; } @override String toString() { return 'UserAddress{id: $id, name: $name, position: $position, tag: $tag, timestmp: $timestmp}'; } } class MyAddressesResponse { List homeAddresses; List officeAddresses; List histories; MyAddressesResponse({ required this.homeAddresses, required this.officeAddresses, required this.histories, }); factory MyAddressesResponse.fromJson(Map json) { return MyAddressesResponse( homeAddresses: (json['homeAddresses'] as List) .map((e) => UserAddress.fromJson(e)) .toList(), officeAddresses: (json['officeAddresses'] as List) .map((e) => UserAddress.fromJson(e)) .toList(), histories: (json['histories'] as List) .map((e) => UserAddress.fromJson(e)) .toList(), ); } }