class Status{ final String label; final String key; final int id; const Status({ this.label, this.key, this.id, }); @override bool operator == (Object other) => identical(this, other) || other is Status && key == other.key && id == other.id; @override int get hashCode => id.hashCode; factory Status.fromStatus(Status old){ return Status( label: old.label, id: old.id, key: old.key, ); } factory Status.fromJson(Map parsedJson){ if(parsedJson["id"] == null && parsedJson["uid"] == null) return null; return Status( label: parsedJson["value"], id: parsedJson["id"] is int ? parsedJson["id"] : int.tryParse(parsedJson["id"] ?? parsedJson["uid"]), ); } factory Status.fromServiceReportJson(Map parsedJson){ return Status( label: parsedJson["value"], id: parsedJson["id"], ); } }