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.
47 lines
965 B
Dart
47 lines
965 B
Dart
|
3 years ago
|
class Lookup{
|
||
|
3 years ago
|
|
||
|
|
final String label;
|
||
|
|
final String key;
|
||
|
|
final int id;
|
||
|
|
|
||
|
3 years ago
|
const Lookup({
|
||
|
3 years ago
|
this.label,
|
||
|
|
this.key,
|
||
|
|
this.id,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
bool operator == (Object other) =>
|
||
|
3 years ago
|
identical(this, other) || other is Lookup &&
|
||
|
3 years ago
|
key == other.key &&
|
||
|
|
id == other.id;
|
||
|
|
|
||
|
|
|
||
|
|
@override
|
||
|
|
int get hashCode => id.hashCode;
|
||
|
|
|
||
|
3 years ago
|
factory Lookup.fromStatus(Lookup old){
|
||
|
|
return Lookup(
|
||
|
3 years ago
|
label: old.label,
|
||
|
|
id: old.id,
|
||
|
|
key: old.key,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
3 years ago
|
factory Lookup.fromJson(Map<String,dynamic> parsedJson){
|
||
|
3 years ago
|
if(parsedJson["id"] == null && parsedJson["uid"] == null) return null;
|
||
|
3 years ago
|
return Lookup(
|
||
|
3 years ago
|
label: parsedJson["value"],
|
||
|
|
id: parsedJson["id"] is int
|
||
|
3 years ago
|
? parsedJson["id"]
|
||
|
|
: int.tryParse(parsedJson["id"] ?? parsedJson["uid"]),
|
||
|
3 years ago
|
);
|
||
|
|
}
|
||
|
|
|
||
|
3 years ago
|
factory Lookup.fromIntIdJson(Map<String,dynamic> parsedJson){
|
||
|
|
return Lookup(
|
||
|
3 years ago
|
label: parsedJson["value"],
|
||
|
|
id: parsedJson["id"],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|