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