title: Flutter: My list view is not updated when I modify an item
body: <p>I am developing a 'todo' flutter app using BloC Architecture pattern.</p>
  
  <p>My 'Home' ui displays todo list, and user can click the item's button to change the status from "todo" to "complete".</p>
  
  <p>When an item is completed, it should display with another color distinct from other todos not completed.</p>
  
  <p>But when I click the "complete" button, the list view is not updated.</p>
  
  <p>Below is my UI code:</p>
  
  <pre class="lang-dart prettyprint-override"><code>class HomePage extends StatelessWidget {
    final TodoRepository _todoRepository;
    final HomeBloc bloc;
  
    HomePage(this._todoRepository) : this.bloc = HomeBloc(_todoRepository);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Center(
          child: StreamBuilder&lt;List&lt;Task&gt;&gt;(
              stream: bloc.todos,
              builder: (context, snapshot) {
                return ListView(
                  children: snapshot.data.map(_buildItem).toList(),
                );
              }),
        ),
      );
    }
  
    Widget _buildItem(Todo todo) {
      if (todo.complete) {
        return completed(todo);
      } else {
        return inCompleted(todo);
      }
    }
  
    Widget inCompleted(Todo todo) {
      return MaterialButton(
        textColor: Colors.white,
        color: Colors.green,
        child: Text("Complete"),
        onPressed: () {
          bloc.done.add(todo);
        }
      );
    }
  
    Widget completed(Todo todo) {
      return MaterialButton(
        textColor: Colors.white,
        color: Colors.red,
        child: Text("Cancel"),
        onPressed: () {
          bloc.done.add(todo);
        }
      );
    }
  }
  
  </code></pre>
  
  <p>And here is my BloC class:</p>
  
  <pre class="lang-dart prettyprint-override"><code>class HomeBloc {
  
    final _getTodosSubject = PublishSubject&lt;List&lt;Todo&gt;&gt;();
    final _doneTodoSubject = PublishSubject&lt;Todo&gt;();
    final _cancelTodoSubject = PublishSubject&lt;Todo&gt;();
  
    final TodoRepository _todoRepository;
  
    var _todos = &lt;Todo&gt;[];
  
    Stream&lt;List&lt;Todo&gt;&gt; get todos =&gt; _getTodosSubject.stream;
  
    Sink&lt;Todo&gt; get done =&gt; _doneTodoSubject.sink;
  
    Sink&lt;Todo&gt; get cancel =&gt; _doneTodoSubject.sink;
  
    HomeBloc(this._todoRepository) {
      _getTodos().then((_) {
        _getTodosSubject.add(_todos);
      });
  
      _doneTodoSubject.listen(_doneTodo);
  
      _cancelTodoSubject.listen(_cancelTodo);
    }
  
    Future&lt;Null&gt; _getTodos() async {
      await _todoRepository.getAll().then((list) {
        _todos = list;
      });
    }
  
    void _doneTodo(Todo todo) {
      todo.complete = true;
      _update(todo);
    }
  
    void _cancelTodo(Todo todo) async {
      todo.complete = false;
      _update(todo);
    }
  
    void _update(Todo todo) async {
      await _todoRepository.save(todo);
      _getTodos();
    }
  
  }
  </code></pre>