mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-02 22:04:30 +01:00
This commit introduces the TaskViewModel, which manages the business logic for tasks. The ViewModel interacts with a mock data source, providing functionalities like fetching tasks, selecting a task, creating, and deleting tasks. Additionally, comprehensive tests for TaskViewModel have been added to ensure its behavior aligns with expectations. The mock data source has also been updated to support the new functionalities. Key Features: - Task management in TaskViewModel. - Tests for each major functionality in TaskViewModel. - Mock data source to simulate data interactions.
21 lines
546 B
Dart
21 lines
546 B
Dart
import 'package:auto_gpt_flutter_client/models/task.dart';
|
|
|
|
/// A list of mock tasks for the application.
|
|
/// TODO: Remove this file when we implement TaskService
|
|
List<Task> mockTasks = [
|
|
Task(id: 1, title: 'Task 1'),
|
|
Task(id: 2, title: 'Task 2'),
|
|
Task(id: 3, title: 'Task 3'),
|
|
// ... add more mock tasks as needed
|
|
];
|
|
|
|
/// Adds a task to the mock data.
|
|
void addTask(Task task) {
|
|
mockTasks.add(task);
|
|
}
|
|
|
|
/// Removes a task from the mock data based on its ID.
|
|
void removeTask(int id) {
|
|
mockTasks.removeWhere((task) => task.id == id);
|
|
}
|