title: Flutter BloC not refresh my view (counter app)
body: <p>I'm trying BloC library with Counter test app but I have a little problem on my view when I use object to increment/decrement my counter.
  MyObject.MyProperty increment or decrement but my view not refreshed. Why?</p>
  
  <p><a href="https://felangel.github.io/bloc/#/fluttercountertutorial" rel="nofollow noreferrer">Sample app</a> with simple int variable.</p>
  
  <p>My code with object:</p>
  
  <pre><code>import 'dart:async';    
  import 'package:flutter/material.dart';    
  import 'package:bloc/bloc.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';    
  
  void main() { 
    runApp(App());
  }
  
  class App extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'Flutter Demo',
        home: BlocProvider(
          builder: (context) =&gt; CounterBloc(),
          child: CounterPage(),
        ),
      );
    }
  }
  
  class TestTest{
    int myProperty; 
  
    TestTest(){
      myProperty = 0;
    }
  }
  
  
  class CounterPage extends StatefulWidget {
    @override
    _CounterPageState createState() =&gt; _CounterPageState();
  }
  
  class _CounterPageState extends State&lt;CounterPage&gt; {
    @override
    Widget build(BuildContext context) {
      final counterBloc = BlocProvider.of&lt;CounterBloc&gt;(context);
  
      return Scaffold(
        appBar: AppBar(title: Text('Counter')),
        body: BlocBuilder&lt;CounterBloc, TestTest&gt;(
          builder: (context, myClassTestTest) { 
            return Center(
              child: Text(
                '${myClassTestTest.myProperty}',
                style: TextStyle(fontSize: 24.0),
              ),
            );
          },
        ),
        floatingActionButton: Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          mainAxisAlignment: MainAxisAlignment.end,
          children: &lt;Widget&gt;[
            Padding(
              padding: EdgeInsets.symmetric(vertical: 5.0),
              child: FloatingActionButton(
                child: Icon(Icons.add),
                onPressed: () {
                  counterBloc.dispatch(CounterEvent.increment);
                },
              ),
            ),
            Padding(
              padding: EdgeInsets.symmetric(vertical: 5.0),
              child: FloatingActionButton(
                child: Icon(Icons.remove),
                onPressed: () {
                  counterBloc.dispatch(CounterEvent.decrement);
                },
              ),
            ),
          ],
        ),
      );
    }
  }
  
  
  enum CounterEvent { increment, decrement }
  
  class CounterBloc extends Bloc&lt;CounterEvent, TestTest&gt; {
    @override
    TestTest get initialState =&gt; TestTest();
  
    @override
    Stream&lt;TestTest&gt; mapEventToState(CounterEvent event) async* {
      switch (event) {
        case CounterEvent.decrement:        
          currentState.myProperty -= 1;
          yield currentState; 
          break;
        case CounterEvent.increment:
          currentState.myProperty += 1;
          yield currentState; 
          break;
      }
    }
  }
  </code></pre>
  
  <p>As you can see I edited the sample app a little just to add my class <code>TestTest</code> with a int property <code>myProperty</code>. When I clic on my button the value in my object change but my view is not refreshed.</p>
  
  <p>How can I fix that?</p>
  
  <p>I found a solution to recreate my TestTest in <code>mapEventToState</code> but it's weird to recreate an entire object just to update a property...</p>
  
  <p>Thank you</p>