import 'package:test_sa/models/lookup.dart'; class PPMCheckList{ int id; Lookup status; String title; String comment; String measuredValue; PPMCheckList({ this.id, this.title, this.status, this.comment, this.measuredValue, }); Map toMap(int visitId) { return { 'id': id ?? 0, "visitId": visitId, if(status != null) 'taskStatusId': status?.id.toString(), if(title != null) 'task': title, if(comment != null) 'taskComment': comment, if(measuredValue != null) 'measuredValue': measuredValue, }; } factory PPMCheckList.fromMap(Map map) { return PPMCheckList( id: map['id'] as int, status: Lookup(id: map["taskStatusId"],name: map["taskStatusName"]), title: map['task'] as String, comment: map['taskComment'] as String, measuredValue: map['measuredValue'] as String, ); } PPMCheckList copyWith({ int id, Lookup status, String title, String comment, String measuredValue, }) { return PPMCheckList( id: id ?? this.id, status: status ?? this.status, title: title ?? this.title, comment: comment ?? this.comment, measuredValue: measuredValue ?? this.measuredValue, ); } }