import 'package:test_sa/models/base.dart'; import 'package:test_sa/models/new_models/building.dart'; class Site extends Base { Site({ this.id, this.custName, this.buildings, }) : super(identifier: id.toString(), name: custName); Site.fromJson(dynamic json) { id = json['id']; identifier = id.toString(); custName = json['custName']; name = custName; if (json['buildings'] != null) { buildings = []; json['buildings'].forEach((v) { buildings.add(Building.fromJson(v)); }); } } num id; String custName; List buildings; Site copyWith({ num id, String custName, List buildings, }) => Site( id: id ?? this.id, custName: custName ?? this.custName, buildings: buildings ?? this.buildings, ); Map toJson() { final map = {}; map['id'] = id; map['custName'] = custName; if (buildings != null) { map['buildings'] = buildings.map((v) => v.toJson()).toList(); } return map; } }