title: Cubit not rebuilding when emiting a new state
body: <p>Whenever I call the toggleLocked event, the BlocBuilder does not rebuild the widget.</p>
  <p>I have looked around a lot on the internet and found this explanation: <a href="https://stackoverflow.com/a/60869187/3290471">https://stackoverflow.com/a/60869187/3290471</a>
  I think that somewhere I incorrectly use the equatable package which results in the fact that the BlocBuilder thinks nothing has changed (while is has).</p>
  <p>I have read the FAQ from the Bloc libray and the three provided solution (props for equatable / not reusing the same state / using fromList) seem to not fix the problem.</p>
  <p>My Cubit:</p>
  <pre class="lang-dart prettyprint-override"><code>class LockCubit extends Cubit&lt;LockState&gt; {
    LockCubit({@required this.repository})
        : assert(repository != null),
          super(LockInitial());
  
    final LocksRepository repository;
  
    Future&lt;void&gt; fetch() async {
      try {
        final locks = await repository.fetchLocks();
        emit(LocksDisplayed().copyWith(locks));
      } on Exception {
        emit(LockError());
      }
    }
  
    Future&lt;void&gt; toggleLocked(int id) async {
      try {
        final locks = await repository.toggleLocked(id);
        emit(LocksDisplayed().copyWith(List.from(locks)));
      } on Exception {
        emit(LockError());
      }
    }
  }
  </code></pre>
  <p>My states:</p>
  <pre class="lang-dart prettyprint-override"><code>abstract class LockState extends Equatable {
    const LockState();
  
    @override
    List&lt;Object&gt; get props =&gt; [];
  }
  
  class LockInitial extends LockState {
    @override
    String toString() =&gt; 'LocksUninitialized';
  }
  
  class LockError extends LockState {
    @override
    String toString() =&gt; 'LockError';
  }
  
  class LocksDisplayed extends LockState {
    final List&lt;Lock&gt; locks;
  
    const LocksDisplayed([this.locks = const []]);
  
    LocksDisplayed copyWith(locks) =&gt; LocksDisplayed(locks ?? this.locks);
  
    @override
    List&lt;Object&gt; get props =&gt; [locks];
  
    @override
    String toString() =&gt; 'LocksDisplayed { locks: $locks }';
  }
  </code></pre>
  <p>My model:</p>
  <pre class="lang-dart prettyprint-override"><code>class Lock extends Equatable {
    Lock({this.id, this.name, this.locked, this.displayed});
  
    final int id;
    final String name;
    final bool locked;
    final bool displayed;
  
    @override
    String toString() =&gt;
        'Lock { id: $id name: $name locked: $locked displayed: $displayed }';
  
    Lock copyWith({id, name, locked, displayed}) =&gt; Lock(
        id: id ?? this.id,
        name: name ?? this.name,
        locked: locked ?? this.locked,
        displayed: displayed ?? this.displayed);
  
    @override
    List&lt;Object&gt; get props =&gt; [id, name, locked, displayed];
  }
  </code></pre>
  <p>My repositotory:</p>
  <pre class="lang-dart prettyprint-override"><code>class LocksRepository {
    List&lt;Lock&gt; locks = [];
  
    Future&lt;List&lt;Lock&gt;&gt; fetchLocks() async {
      // This is a temporary implementation
      // In the future the data should be fetched from a provider
  
      locks = [
        new Lock(
          id: 0,
          name: 'Voordeur',
          locked: false,
        ),
        new Lock(
          id: 1,
          name: 'Achterdeur',
          locked: false,
        )
      ];
  
      return locks;
    }
  
    Future&lt;List&lt;Lock&gt;&gt; toggleLocked(int id) async {
      // This is a temporary implementation
      // In the future a request to change a lock should be made and then the specific lock should be retrieved back and edited.
  
      locks[id] = locks[id].copyWith(locked: !locks[id].locked);
  
      return locks;
    }
  }
  </code></pre>
  <p>I am changing a state with the following trigger:</p>
  <pre class="lang-dart prettyprint-override"><code>context.read&lt;LockCubit&gt;().toggleLocked(focusedIndex);
  </code></pre>
  <p>I am using BlocBuilder like this to build the state:</p>
  <pre class="lang-dart prettyprint-override"><code>BlocBuilder&lt;LockCubit, LockState&gt;(builder: (context, state) {
        print('State Changed');
  
        if (state is LockInitial) {
          return Text('lockInitial');
        }
  
        if (state is LocksDisplayed) {
          return Swiper(
              itemBuilder: (BuildContext context, int index) {
                return Column(
                  children: [
                    Text(state.locks[index].name),
                    Text(state.locks[index].locked.toString())
                  ],
                );
              },
              onIndexChanged: onIndexChanged,
              loop: true,
              itemCount: state.locks.length);
        }
  
        if (state is LockError) {
          return Text('lockError');
        }
  
        return Container();
      });
  </code></pre>
  <p>All help would be very appreciated.</p>