@@ -17,27 +17,24 @@ class ForgetPassVerifyScreen extends StatefulWidget {
17
17
class _ForgetPassVerifyScreenState extends State <ForgetPassVerifyScreen > {
18
18
19
19
bool emptyPassword = false ;
20
- bool emptyUsername = false ;
21
20
bool emptyOTP = false ;
22
21
23
22
bool isPasswordValid = true ;
24
23
bool isOTPNumeric = true ;
25
24
bool isOTPCorrectLength = true ;
26
25
bool arePasswordsMatch = true ;
27
- bool isUsernameValid = true ;
26
+ bool emptyMail = false ;
28
27
29
28
30
29
final TextEditingController passwordController = TextEditingController ();
31
30
final TextEditingController OTPController = TextEditingController ();
32
- final TextEditingController usernameController = TextEditingController ();
33
31
final TextEditingController confirmPasswordController = TextEditingController ();
34
-
32
+ String email = "" ;
35
33
36
34
// Add more validation logic for password as needed
37
35
void validatePassword (String password) {
38
36
setState (() {
39
37
emptyPassword = false ;
40
- emptyUsername = false ;
41
38
emptyOTP = false ;
42
39
43
40
if (password.isEmpty){
@@ -77,24 +74,10 @@ class _ForgetPassVerifyScreenState extends State<ForgetPassVerifyScreen> {
77
74
});
78
75
}
79
76
80
- void validateUsername (String username){
81
- setState (() {
82
- emptyPassword = false ;
83
- emptyOTP = false ;
84
- emptyUsername = false ;
85
- if (username.isEmpty) {
86
- isUsernameValid = true ;
87
- } else {
88
- isUsernameValid = username.length >=
89
- 6 ; // For example, username should be at least 6 characters
90
- }
91
- });
92
- }
93
77
94
78
void validateOTP (String OTP ){
95
79
setState (() {
96
80
emptyPassword = false ;
97
- emptyUsername = false ;
98
81
emptyOTP = false ;
99
82
100
83
RegExp numericPattern = RegExp (r'^-?[0-9]+$' ); //check if the string is numeric or not
@@ -130,7 +113,6 @@ class _ForgetPassVerifyScreenState extends State<ForgetPassVerifyScreen> {
130
113
131
114
void resetPass () async {
132
115
String password = passwordController.text;
133
- String username = usernameController.text;
134
116
String confirmPassword = confirmPasswordController.text;
135
117
String OTP = OTPController .text;
136
118
@@ -139,25 +121,25 @@ class _ForgetPassVerifyScreenState extends State<ForgetPassVerifyScreen> {
139
121
emptyPassword = true ;
140
122
});
141
123
}
142
- if (username .isEmpty) {
124
+ if (email .isEmpty){
143
125
setState (() {
144
- emptyUsername = true ;
126
+ emptyMail = true ;
145
127
});
146
128
}
147
129
if (OTP .isEmpty) {
148
130
setState (() {
149
131
emptyOTP = true ;
150
132
});
151
133
}
152
- if (emptyPassword || emptyUsername || emptyOTP) {
134
+ if (emptyPassword || emptyMail || emptyOTP) {
153
135
return ;
154
136
}
155
137
// Perform code verification and navigate to the next screen if successful
156
138
PasswordResetVerification passwordResetVerification = PasswordResetVerification ();
157
139
158
140
try {
159
141
160
- Response response = await passwordResetVerification.submitPass (int .parse (OTP ) , username , password);
142
+ Response response = await passwordResetVerification.submitPass (int .parse (OTP ) , email , password);
161
143
if (response.statusCode == 201 ) {
162
144
163
145
if (! context.mounted) return ;
@@ -193,6 +175,8 @@ class _ForgetPassVerifyScreenState extends State<ForgetPassVerifyScreen> {
193
175
194
176
@override
195
177
Widget build (BuildContext context) {
178
+ final data = ModalRoute .of (context)! .settings.arguments as String ;
179
+ email = data;
196
180
197
181
return Scaffold (
198
182
resizeToAvoidBottomInset: true ,
@@ -219,13 +203,6 @@ class _ForgetPassVerifyScreenState extends State<ForgetPassVerifyScreen> {
219
203
errorText: errorTextOTP (),
220
204
),
221
205
const SizedBox (height: 10.0 ),
222
- CustomTextField (
223
- labelText: 'Username' ,
224
- controller: usernameController,
225
- onChanged: validateUsername,
226
- errorText: isUsernameValid ? "" : 'Enter a valid username!' ,
227
- ),
228
- const SizedBox (height: 10.0 ),
229
206
CustomTextField (
230
207
labelText: 'New Password' ,
231
208
controller: passwordController,
@@ -249,12 +226,6 @@ class _ForgetPassVerifyScreenState extends State<ForgetPassVerifyScreen> {
249
226
padding: const EdgeInsets .all (10 ),
250
227
child: Column (
251
228
children: [
252
- Text (
253
- emptyUsername ? 'Username cannot be empty' : '' ,
254
- style: TextStyle (
255
- color: Colors .red[900 ],
256
- ),
257
- ),
258
229
Text (
259
230
emptyPassword ? 'Password cannot be empty' : '' ,
260
231
style: TextStyle (
0 commit comments