-
Notifications
You must be signed in to change notification settings - Fork 1
/
signupandupdatedata.dart
58 lines (37 loc) · 1.18 KB
/
signupandupdatedata.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
55
56
57
58
bool passwordValidator(String password, String confirmPassword) {
if(password != confirmPassword){
return false;
}else{
return true;
}
}
Map<String, dynamic> setUserData(String email, String userName, {String? password, String? confirmPassword}) {
Map<String, dynamic> userData = {
'email' : email,
'userName' : userName,
'password' : password,
'confirmPassword' : confirmPassword
};
if(password == null) {
userData.remove('password');
userData.remove('confirmPassword');
}
return userData;
}
signUp(String email, String userName, String requiredPassword, String requiredConfirmPassword) {
bool passValid = passwordValidator(requiredPassword, requiredConfirmPassword);
if(passValid == true){
Map<String, dynamic> userData = setUserData(email, userName, password: requiredPassword, confirmPassword: requiredConfirmPassword);
print(userData);
}else{
print('password dont match');
}
}
updateData(String email, String userName) {
Map<String, dynamic> userData = setUserData(email, userName);
print(userData);
}
void main() {
signUp('basel.com', 'basel', '1234', '1234');
updateData('basel.com', 'basel allam');
}