Repository navigation
Expand file tree
/
Copy pathstudent.dart.txt
More file actions
101 lines (96 loc) · 2.76 KB
/
Copy pathstudent.dart.txt
File metadata and controls
101 lines (96 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
class Student {
final int? id;
final String firstName;
final String lastName;
final String email;
final String phone;
final String rollNumber;
final String className;
final String dateOfBirth;
final String address;
final double gpa;
final int attendancePercentage;
final String enrollmentDate;
final String profileImagePath;
Student({
this.id,
required this.firstName,
required this.lastName,
required this.email,
required this.phone,
required this.rollNumber,
required this.className,
required this.dateOfBirth,
required this.address,
this.gpa = 0.0,
this.attendancePercentage = 100,
required this.enrollmentDate,
this.profileImagePath = '',
});
String get fullName => '$firstName $lastName';
Map<String, dynamic> toMap() {
return {
'id': id,
'firstName': firstName,
'lastName': lastName,
'email': email,
'phone': phone,
'rollNumber': rollNumber,
'className': className,
'dateOfBirth': dateOfBirth,
'address': address,
'gpa': gpa,
'attendancePercentage': attendancePercentage,
'enrollmentDate': enrollmentDate,
'profileImagePath': profileImagePath,
};
}
factory Student.fromMap(Map<String, dynamic> map) {
return Student(
id: map['id'],
firstName: map['firstName'] ?? '',
lastName: map['lastName'] ?? '',
email: map['email'] ?? '',
phone: map['phone'] ?? '',
rollNumber: map['rollNumber'] ?? '',
className: map['className'] ?? '',
dateOfBirth: map['dateOfBirth'] ?? '',
address: map['address'] ?? '',
gpa: map['gpa']?.toDouble() ?? 0.0,
attendancePercentage: map['attendancePercentage'] ?? 100,
enrollmentDate: map['enrollmentDate'] ?? '',
profileImagePath: map['profileImagePath'] ?? '',
);
}
Student copyWith({
int? id,
String? firstName,
String? lastName,
String? email,
String? phone,
String? rollNumber,
String? className,
String? dateOfBirth,
String? address,
double? gpa,
int? attendancePercentage,
String? enrollmentDate,
String? profileImagePath,
}) {
return Student(
id: id ?? this.id,
firstName: firstName ?? this.firstName,
lastName: lastName ?? this.lastName,
email: email ?? this.email,
phone: phone ?? this.phone,
rollNumber: rollNumber ?? this.rollNumber,
className: className ?? this.className,
dateOfBirth: dateOfBirth ?? this.dateOfBirth,
address: address ?? this.address,
gpa: gpa ?? this.gpa,
attendancePercentage: attendancePercentage ?? this.attendancePercentage,
enrollmentDate: enrollmentDate ?? this.enrollmentDate,
profileImagePath: profileImagePath ?? this.profileImagePath,
);
}
}