Files
afterwork/lib/data/models/user_model.dart
2024-09-01 04:08:50 +00:00

38 lines
925 B
Dart

import 'package:afterwork/domain/entities/user.dart';
class UserModel extends User {
const UserModel({
required String userId, // Utilisez `id` pour correspondre à l'entité User
required String nom,
required String prenoms,
required String email,
required String motDePasse,
}) : super(
userId: userId,
nom: nom,
prenoms: prenoms,
email: email,
motDePasse: motDePasse,
);
factory UserModel.fromJson(Map<String, dynamic> json) {
return UserModel(
userId: json['id'] ?? '',
nom: json['nom'] ?? '',
prenoms: json['prenoms'] ?? '',
email: json['email'] ?? '',
motDePasse: json['motDePasse'] ?? '',
);
}
Map<String, dynamic> toJson() {
return {
'id': userId, // Utilisez `id` pour correspondre à l'entité User
'nom': nom,
'prenoms': prenoms,
'email': email,
'motDePasse': motDePasse,
};
}
}