didvan-app/lib/models/user.dart

47 lines
1.0 KiB
Dart

class User {
final int id;
final String phoneNumber;
final String fullName;
final String? username;
final String? photo;
const User({
required this.id,
required this.username,
required this.phoneNumber,
required this.photo,
required this.fullName,
});
factory User.fromJson(Map<String, dynamic> json) => User(
id: json['id'],
username: json['username'],
phoneNumber: json['phoneNumber'],
photo: json['photo'],
fullName: json['fullName']);
Map<String, dynamic> toJson() => {
'id': id,
'username': username,
'phoneNumber': phoneNumber,
'photo': photo,
'fullName': fullName,
};
User copyWith({
int? id,
String? username,
String? phoneNumber,
String? photo,
String? fullName,
}) {
return User(
id: id ?? this.id,
username: username ?? this.username,
phoneNumber: phoneNumber ?? this.phoneNumber,
photo: photo ?? this.photo,
fullName: fullName ?? this.fullName,
);
}
}