fixed issues

fatima
Fatimah Alshammari 4 years ago
parent 47f10738d7
commit 5b8750702e

@ -107,9 +107,9 @@ class UserApiClent {
//return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
}
Future<Response> ChangePassword(String currentPasswor, String newPassword) async {
Future<Response> ChangePassword(String currentPassword, String newPassword) async {
var postParams = {
"currentPasswor": currentPasswor,
"currentPassword": currentPassword,
"newPassword": newPassword,
};
return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);

@ -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(),

@ -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());

@ -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<ChangePasswordPage> createState() => _ChangePasswordPageState();
@ -29,7 +27,7 @@ class ChangePasswordPage extends StatefulWidget {
class _ChangePasswordPageState extends State<ChangePasswordPage> {
String newPassword = "";
String currentPasswor = '';
String currentPassword = " ";
@override
Widget build(BuildContext context) {
@ -55,7 +53,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
),
),
obscureText: true,
onChanged: (v) => currentPasswor = v,
onChanged: (v) => currentPassword = v,
),
12.height,
TextFormField(
@ -75,7 +73,8 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
ShowFillButton(
title: "Confirm",
width: double.infinity,
onPressed: () {changePassword(context);
onPressed: () {
changePassword(context);
},
),
],
@ -88,12 +87,12 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
Future<void> 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 ?? "");
}

Loading…
Cancel
Save