diff --git a/lib/api/client/user_api_client.dart b/lib/api/client/user_api_client.dart index 81c46ec..7b44fdf 100644 --- a/lib/api/client/user_api_client.dart +++ b/lib/api/client/user_api_client.dart @@ -107,9 +107,9 @@ class UserApiClent { //return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams); } - Future ChangePassword(String currentPasswor, String newPassword) async { + Future ChangePassword(String currentPassword, String newPassword) async { var postParams = { - "currentPasswor": currentPasswor, + "currentPassword": currentPassword, "newPassword": newPassword, }; return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams); diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 02a17a2..b4fe535 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -66,7 +66,7 @@ class AppRoutes { defineLicense: (context) => DefineLicensePage(), vertifyPassword: (context) => VerifyPasswordPage(), confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String), - changePassword: (context) => ChangePasswordPage(ModalRoute.of(context)!.settings.arguments as String), + changePassword: (context) => ChangePasswordPage(), //Home page dashboard: (context) => DashboardPage(), diff --git a/lib/models/user/change_password.dart b/lib/models/user/change_password.dart index a49437b..fc74d4b 100644 --- a/lib/models/user/change_password.dart +++ b/lib/models/user/change_password.dart @@ -3,7 +3,7 @@ import 'dart:convert'; -ChangePassword confirmPasswordFromJson(String str) => ChangePassword.fromJson(json.decode(str)); +ChangePassword changePasswordFromJson(String str) => ChangePassword.fromJson(json.decode(str)); String changePasswordToJson(ChangePassword data) => json.encode(data.toJson()); diff --git a/lib/pages/user/change_password_page.dart b/lib/pages/user/change_password_page.dart index 8db8397..30bc38c 100644 --- a/lib/pages/user/change_password_page.dart +++ b/lib/pages/user/change_password_page.dart @@ -19,9 +19,7 @@ import 'dart:convert'; import 'package:http/http.dart'; class ChangePasswordPage extends StatefulWidget { - String userToken; - ChangePasswordPage(this.userToken, {Key? key}) : super(key: key); @override State createState() => _ChangePasswordPageState(); @@ -29,7 +27,7 @@ class ChangePasswordPage extends StatefulWidget { class _ChangePasswordPageState extends State { String newPassword = ""; - String currentPasswor = ''; + String currentPassword = " "; @override Widget build(BuildContext context) { @@ -55,7 +53,7 @@ class _ChangePasswordPageState extends State { ), ), obscureText: true, - onChanged: (v) => currentPasswor = v, + onChanged: (v) => currentPassword = v, ), 12.height, TextFormField( @@ -75,7 +73,8 @@ class _ChangePasswordPageState extends State { ShowFillButton( title: "Confirm", width: double.infinity, - onPressed: () {changePassword(context); + onPressed: () { + changePassword(context); }, ), ], @@ -88,12 +87,12 @@ class _ChangePasswordPageState extends State { Future changePassword(BuildContext context) async { if(validateStructure(newPassword??"")){ Utils.showLoading(context); - Response res = await UserApiClent().ChangePassword(currentPasswor, newPassword); + Response res = await UserApiClent().ChangePassword(currentPassword, newPassword); Utils.hideLoading(context); ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body)); if (data.messageStatus == 1) { Utils.showToast("Password is Updated"); - navigateWithName(context, AppRoutes.loginWithPassword); + navigateWithName(context, AppRoutes.dashboard); } else { Utils.showToast(data.message ?? ""); }