recoverPasswordService function
Implementation
Future<Map<String, dynamic>> recoverPasswordService(
BuildContext context, {
required String email,
required String password,
required String confirmPassword,
required int code,
}) async {
final bool internetStatus = await checkInternetConnection();
if (!internetStatus) {
Transitions(
context: context,
child: const NoInternetPage(),
removeUntil: true,
);
return <String, dynamic>{
'no_network': internetStatus,
};
}
final http.Response response = await http.post(
Uri.parse(
'${ServicesEnvironment.protocol}${ServicesEnvironment.authority}${ServicesEnvironment.unencodedPath}$_endPoint',
),
headers: <String, String>{
'Content-Type': 'application/json; charset=utf-8',
},
body: json.encode(
<String, dynamic>{
'email': email,
'password': password,
'confirm_password': confirmPassword,
'code': code,
},
),
);
Map<String, dynamic> decodedResponse;
try {
decodedResponse = json.decode(response.body);
} catch (exception) {
return Future.error(GlobalMessagesEnvironment.genericError);
}
return decodedResponse;
}