removePhoto method

void removePhoto()

Implementation

void removePhoto() async {
  try {
    final response = await Requests.getDio().put(
      '/api/users/update-user',
      data: {
        'imgUrl': null,
      },
    );

    if (response.statusCode == 200) {
      await authenticationController.getUserProfile();
      DefaultSnackbar.show("Success", "Removed profile photo successfully");
    } else {
      log('Error removing profile photo: ${response.data}');
      final String? errorMsg = response.data?['message'];
      DefaultSnackbar.show("Error", errorMsg ?? "Error occurred");
    }
  } catch (_) {
    log('Error removing profile photo: ${_.toString()}');
    DefaultSnackbar.show("Error", "Error occurred");
  }
}