forgotPassword method

Future<void> forgotPassword({
  1. required String email,
})

Sends the user an email to reset their password.

Implementation

Future<void> forgotPassword({required String email}) async {
  final uri = Uri.https(authority, '/users/forgot');
  final payload = {'email': email};
  late Response<Map<String, dynamic>> res;

  try {
    res = await _dio.postUri(uri, data: payload);
  } on DioError catch (e, s) {
    throw PindoError(
      message: (e.response?.data as Map)['message'],
      statusCode: (e.response?.data as Map)['status'] ?? res.statusCode,
      type: e.type.valueToString,
      stackTrace: s,
    );
  } on TypeError {
    throw PindoCastingError();
  } on Exception {
    rethrow;
  }
}