upvoteTask method

Future<int> upvoteTask(
  1. int taskId
)

Implementation

Future<int> upvoteTask(int taskId) async {
  try {
    final response = await _dio.get('tasks/upvote/$taskId');
    if (response.statusCode == 200) {
      final data = response.data;
      final votes = data['votes'] as int;
      print("Vote incremented successfully");
      return votes;
    } else {
      print("Failed to increment votes: ${response.statusCode}");
      throw Exception('Failed to increment votes');
    }
  } catch (error) {
    print("Error incrementing votes: $error");
    throw Exception('Error incrementing votes');
  }
}