class Nursery { int cropId; String executeDate; String description; String substrates; num quantity; num seedLength; num seedIncubationTime; List nurseryDetail; Nursery( {this.cropId, this.executeDate, this.description, this.substrates, this.quantity, this.seedLength, this.seedIncubationTime, this.nurseryDetail}); Nursery.fromJson(Map json) { cropId = json['cropId']; executeDate = json['executeDate']; description = json['description']; substrates = json['substrates']; quantity = json['quantity']; seedLength = json['seedLength']; seedIncubationTime = json['seedIncubationTime']; if (json['nurseryDetail'] != null) { nurseryDetail = new List(); json['nurseryDetail'].forEach((v) { nurseryDetail.add(new NurseryDetail.fromJson(v)); }); } } Map toJson() { final Map data = new Map(); data['cropId'] = this.cropId; data['executeDate'] = this.executeDate; data['description'] = this.description; data['substrates'] = this.substrates; data['quantity'] = this.quantity; data['seedLength'] = this.seedLength; data['seedIncubationTime'] = this.seedIncubationTime; if (this.nurseryDetail != null) { data['nurseryDetail'] = this.nurseryDetail.map((v) => v.toJson()).toList(); } return data; } } class NurseryDetail { int id; String workerName; String trayNumber; bool isExpanded = false; NurseryDetail({this.workerName, this.trayNumber}); NurseryDetail.clone(NurseryDetail nurseryDetail) { this.id = nurseryDetail.id; this.workerName = nurseryDetail.workerName; this.trayNumber = nurseryDetail.trayNumber; this.isExpanded = nurseryDetail.isExpanded; } NurseryDetail.fromJson(Map json) { id = json['id']; workerName = json['workerName']; trayNumber = json['trayNumber']; } Map toJson() { final Map data = new Map(); data['id'] = this.id; data['workerName'] = this.workerName; data['trayNumber'] = this.trayNumber; return data; } }