I'm working with flutter and the bloc pattern. The Todo tutorial (https://bloclibrary.dev/#/fluttertodostutorial?id=bloc) explains the bloc very well.
But no I want to extend the example app with information about "object sync completed/running". I've attached an image with my idea of how it should work.
I think the following function is doing something similar - change complete bool. But how to change the function to change the bool of 1 obj after the async call and fire it directly to the UI. After obj 1 go to obj 2 and so on.
Stream<TodosState> _mapToggleAllToState() async* {
if (state is TodosLoadSuccess) {
final allComplete =
(state as TodosLoadSuccess).todos.every((todo) => todo.complete);
final List<Todo> updatedTodos = (state as TodosLoadSuccess)
.todos
.map((todo) => todo.copyWith(complete: !allComplete))
.toList();
yield TodosLoadSuccess(updatedTodos);
_saveTodos(updatedTodos);
}
}
I hope that you understand my explanation and can help me :-)