-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusermodels.dart
54 lines (38 loc) · 903 Bytes
/
usermodels.dart
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
import 'demodata.dart';
class User{
String name;
String email;
String? password;
int? mobileNumber;
User(this.name, this.email, this.password, this.mobileNumber);
factory User.fromMap(Map<String, dynamic> i) {
return User(
i['name'],
i['email'],
i['password'],
i['mobileNumber']
);
}
}
class UserController{
User createUserObj(String name, String email, String password, int mobileNumber) {
User newUser = User(name, email, password, mobileNumber);
return newUser;
}
}
// function create object
// function create list of object
main() {
List<User> allUsers = [];
for(Map<String, dynamic> i in user) {
// User newUser = User(
// i['name'],
// i['email'],
// i['password'],
// i['mobileNumber']
// );
User newUser = User.fromMap(i);
allUsers.add(newUser);
}
print(allUsers);
}