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/lookup.dart

46 lines
1.2 KiB
Dart

import 'base.dart';
class Lookup extends Base {
int? id; // Now nullable
int? value; // Now nullable
@override
String? name; // Now nullable
Lookup({this.id, this.value, this.name}) : super(identifier: id?.toString(), name: name);
@override
bool operator ==(Object other) => identical(this, other) || other is Lookup && ((value != null && value == other.value) || (id != null && id == other.id));
@override
int get hashCode => id.hashCode ^ value.hashCode; // Use XOR for hash code combination
Map<String, dynamic> toJson() {
// Return a Map instead of calling a function
return {"id": id, "name": name, "value": value};
}
static Lookup? fromStatus(Lookup? old) {
// Now accepts nullable Lookup and returns nullable Lookup
if (old == null) return null;
return Lookup(
name: old.name,
id: old.id,
value: old.value,
);
}
// CreatedBy.fromJson(dynamic json) {
// userId = json['userId'] ?? '';
// userName = json['userName'] ?? '';
// }
factory Lookup.fromJson(Map<String, dynamic> parsedJson) {
// if (parsedJson == null) return null;
return Lookup(
name: parsedJson["name"],
id: parsedJson["id"],
value: parsedJson["value"],
);
}
}