title: flutter: BLoC Builder not updating, though I see new/different state in debugger
body: <p>My 2nd strange event today. When I follow the debugger inside bloc.dart (the library, not my file) and  I see that <code>transition.nextState == state &amp;&amp; _emitted</code> is <code>false</code>, it does not update my widget (nextState has list size 2, state has 10 - _emitted is true). To my understanding the builder should be ok, is there any other spot to look at why it does not update?</p>
  <p>Just to explain the logic before I show the code</p>
  <ol>
  <li><p>I fetch my data upon app launch with</p>
  <pre><code>BlocProvider(create: (context) =&gt;
    LogicGraphsPStmntBloc(logicGraphsRepository:
    logicGraphsRepository)..add(LogicGraphsNextProblemRequested()),
  </code></pre>
  </li>
  <li><p>this returns a list of 10 strings, which I store in my _bloc.dart file (not sure if this is state of the art)</p>
  </li>
  <li><p>These 10 strings are sent via the state <code>LogicGraphsPStmntLoadSuccess(statements)</code> and are properly rendered as buttons</p>
  </li>
  <li><p>If I click a button, only the 1st and the selected string shall be shown. The event is properly triggered with <code>onPressed: () {BlocProvider.of&lt;LogicGraphsPStmntBloc&gt;(context).add(LogicGraphsPStmntCollapsed(statement: index-1));},</code></p>
  </li>
  <li><p>This properly triggers the state <code>yield LogicGraphsPStmntLoadSuccess(statementsShown);</code> with  now only 2 elements in the list (as compared to 10 in step 3) but it does not cause a rerendering</p>
  </li>
  <li><p>If I step into the state with the debugger, I can see that both states have a different number of elements.</p>
  </li>
  </ol>
  <p>my states</p>
  <pre class="lang-dart prettyprint-override"><code>abstract class LogicGraphsPStmntState extends Equatable {
    const LogicGraphsPStmntState();
    @override
    List&lt;Object&gt; get props =&gt; [];
  }
  
  class LogicGraphsPStmntLoadSuccess extends LogicGraphsPStmntState {
    const LogicGraphsPStmntLoadSuccess([this.statements = const []]);
    final List&lt;String&gt; statements;
  
    @override
    List&lt;Object&gt; get props =&gt; [];
  
    @override
    String toString() =&gt; 'LogicGraphsPStmntLoadSuccess { statements: $statements }';
  }
  </code></pre>
  <p>my bloc (not exactly, because the code inside my sub functions to release a state are not reached as described in <a href="https://stackoverflow.com/questions/63955853/flutter-code-does-not-step-into-function-within-bloc-definition-adaption-of-to">my other issue</a>. So currently I have those sub functions lines as spaghetti in the mapEventToState=</p>
  <pre class="lang-dart prettyprint-override"><code>class LogicGraphsPStmntBloc extends Bloc&lt;LogicGraphsPStmntEvent, LogicGraphsPStmntState&gt; {
    LogicGraphsPStmntBloc({@required this.logicGraphsRepository}) : super(LogicGraphsPStmntInProgress());
    final LogicGraphsRepository logicGraphsRepository;
    List&lt;String&gt; statements;
    int currentProblem = -1;
  
    @override
    Stream&lt;LogicGraphsPStmntState&gt; mapEventToState(LogicGraphsPStmntEvent event) async* {
          if (event is LogicGraphsNextProblemRequested) {
            _mapLGPStmntNewProblemRequested();
            _mapLGPStmntLoadRequested(currentProblem);
          }
          else if (event is LogicGraphsPStmntLoadRequested) {
            _mapLGPStmntLoadRequested(currentProblem);
          }
          else if (event is LogicGraphsPStmntCollapsed) {
            _mapLGPStmntCollapseRequested(event);
    }
    Stream&lt;LogicGraphsPStmntState&gt; _mapLGPStmntNewProblemRequested() async* {
          try {
            currentProblem =
            await getNextProblem(currentProblem == null ? -1 : currentProblem);
            statements =
            await logicGraphsRepository.getProblemStmntList(currentProblem);
            _mapLGPStmntLoadRequested(currentProblem);
          } catch (_) {
            yield LogicGraphsPStmntLoadFailure();
          }
    }
    Stream&lt;LogicGraphsPStmntState&gt; _mapLGPStmntLoadRequested(int problem) async* {
            try {
              yield LogicGraphsPStmntLoadSuccess(statements);
            } catch (_) {
              yield LogicGraphsPStmntLoadFailure();
            }
    }
    Stream&lt;LogicGraphsPStmntState&gt; _mapLGPStmntCollapseRequested(
            LogicGraphsPStmntCollapsed event) async* {
            List&lt;String&gt; statementsShown = [];
            statementFocussed = event.statement;
            statementsShown.add(statements[0]);
            statementsShown.add(statements[statementFocussed]);
            yield LogicGraphsPStmntLoadSuccess(statementsShown);
    }
  }
  </code></pre>
  <p>my widgets</p>
  <pre class="lang-dart prettyprint-override"><code>class LogicGraphPage extends StatelessWidget {
    final LogicGraphsRepository logicGraphsRepository = LogicGraphsRepository(
        logicGraphsApiClient: LogicGraphsApiClient());
  
    @override
    Widget build(BuildContext context) {
      return CupertinoPageScaffold(
        child: BlocProvider(
          create: (context) =&gt;
          LogicGraphsPStmntBloc(logicGraphsRepository: logicGraphsRepository)
            ..add(LogicGraphsNextProblemRequested()),
            child:BlocBuilder&lt;LogicGraphsPStmntBloc, LogicGraphsPStmntState&gt;(
              builder: (context, state) {
                if (state is LogicGraphsPStmntLoadSuccess) {
                  final List&lt;String&gt; statements = state.statements;
                  return ListView.builder(
                      itemCount: statements.length,
                      itemBuilder: (BuildContext context, int index) {
                        return CupertinoButton(
                          padding: EdgeInsets.all(0),
                          child: Text(statements[index])
                          onPressed: () {BlocProvider.of&lt;LogicGraphsPStmntBloc&gt;(context).add(LogicGraphsPStmntCollapsed(statement: index-1));},
                        );
                      });
                }
                else return Container();
              }
          )
        ),
      );
    }
  }
  </code></pre>
  <p>The function inside the bloc.dart library where I would assume that the new state is emitted. You see the line <code>if (transition.nextState == state &amp;&amp; _emitted) return;</code>. Next state has 2 elements, state has 10, _emitted is true, so I would assume the code to continue. Instead the return is triggered and lines with<code>emit(transition.nextState);</code> are skipped.</p>
  <p>Any help is highly appreciated, since this is my first experience with BLoC/equatable and flutter in general is also still quite new to me. But I am progressing!</p>
  <pre class="lang-dart prettyprint-override"><code> void _bindEventsToStates() {
      _transitionSubscription = transformTransitions(
        transformEvents(
          _eventController.stream,
              (event) =&gt; mapEventToState(event).map(
                (nextState) =&gt; Transition(
              currentState: state,
              event: event,
              nextState: nextState,
            ),
          ),
        ),
      ).listen(
            (transition) {
          if (transition.nextState == state &amp;&amp; _emitted) return; // &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
          try {
            onTransition(transition);
            emit(transition.nextState);
          } on dynamic catch (error, stackTrace) {
            onError(error, stackTrace);
          }
          _emitted = true;
        },
        onError: onError,
      );
    }
  </code></pre>