You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/models/status.dart

47 lines
977 B
Dart

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<String,dynamic> 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<String,dynamic> parsedJson){
return Status(
label: parsedJson["value"],
id: parsedJson["id"],
);
}
}