44 lines
1.0 KiB
Dart
44 lines
1.0 KiB
Dart
class UserModel {
|
|
String id;
|
|
String name;
|
|
String uniqueId;
|
|
String email;
|
|
bool isVerified;
|
|
|
|
UserModel({
|
|
required this.id,
|
|
required this.name,
|
|
required this.uniqueId,
|
|
required this.email,
|
|
required this.isVerified,
|
|
});
|
|
|
|
// Factory constructor to create an instance of UserModel from a JSON map
|
|
factory UserModel.fromJson(Map<String, dynamic> json) {
|
|
return UserModel(
|
|
id: json['_id'] ??"",
|
|
name: json['name'] ??"Sarita",
|
|
uniqueId: json['uniqueId'] ??"1234",
|
|
email: json['email'] ??"",
|
|
isVerified: json['isVerified'] as bool? ??false,
|
|
);
|
|
}
|
|
|
|
// Method to convert an instance of UserModel to a JSON map
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'_id': id,
|
|
'name': name,
|
|
'uniqueId': uniqueId,
|
|
'email': email,
|
|
'isVerified': isVerified,
|
|
};
|
|
}
|
|
|
|
// Override toString() to provide a readable output
|
|
@override
|
|
String toString() {
|
|
return 'UserModel{id: $id, name: $name, uniqueId: $uniqueId, email: $email, isVerified: $isVerified}';
|
|
}
|
|
}
|