|
|
|
|
@ -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 ?? "");
|
|
|
|
|
}
|
|
|
|
|
|