submitNewTask method

Future<Map<String, dynamic>> submitNewTask(
  1. String title,
  2. String description
)

Implementation

Future<Map<String, dynamic>> submitNewTask(
    String title, String description) async {
  try {
    final response = await _dio.get('tasks/create', queryParameters: {
      'title': title,
      'description': description,
    });

    if (response.statusCode == 200 || response.statusCode == 201) {
      final data = response.data['task'] as Map<String, dynamic>;
      print("Task submitted successfully");
      return data;
    } else {
      print("Failed to submit task: ${response.statusCode}");
      throw Exception('Failed to submit task');
    }
  } catch (error) {
    print("Error submitting task: $error");
    throw Exception('Error submitting task');
  }
}