чота там добавила
This commit is contained in:
parent
9f3df340ab
commit
f551dc58a9
@ -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),
|
||||
|
@ -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} выполнено');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user