чота там добавила

This commit is contained in:
Полина Чубыкина 2024-10-02 10:47:19 +04:00
parent 9f3df340ab
commit f551dc58a9
2 changed files with 7 additions and 5 deletions

View File

@ -57,7 +57,7 @@ class _MyHomePageState extends State<MyHomePage> {
final TaskManager _taskManager = TaskManager();
void _addRandomTask() {
Task _addRandomTask() {
const priorities = TaskPriority.values;
final randomPriority = priorities[Random().nextInt(priorities.length)];
final newTask = Task('Task ${_taskManager.getTasks().length + 1}', randomPriority);
@ -65,6 +65,7 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {
_color = Color((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
});
return newTask;
}
@override
@ -96,8 +97,8 @@ class _MyHomePageState extends State<MyHomePage> {
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
_addRandomTask();
await _taskManager.simulateTaskProcessing();
Task task = _addRandomTask();
await _taskManager.simulateTaskProcessing(task);
},
backgroundColor: _color,
child: const Icon(Icons.add),

View File

@ -11,8 +11,9 @@ class TaskManager {
return _tasks;
}
Future<void> simulateTaskProcessing() async {
Future<void> simulateTaskProcessing(Task task) async {
await Future.delayed(const Duration(seconds: 2));
print('Задание выполнено');
print('Задание ${task.title} выполнено');
}
}