title: Flutter: bloc test problem with comparing expected and actual
body: <p>I have tests like the below:</p>
  <pre class="lang-dart prettyprint-override"><code>      blocTest(
          'emits [ViewData.loading and ViewData.loaded] when GetRepositories is added',
          build: () {
            when(
              () =&gt; useCase.getRepositories(),
            ).thenAnswer((_) async =&gt; Right(repositoriesDummyEntityFromRemote));
            return homeBloc;
          },
          act: (HomeBloc bloc) =&gt; bloc.add(GetRepositories()),
          expect: () =&gt; [
            HomeState(
              statusRepositories: ViewData.loading(message: 'Loading'),
              isShowTitle: false,
            ),
            HomeState(
              statusRepositories:
                  ViewData.loaded(data: repositoriesDummyEntityFromRemote),
              isShowTitle: false,
            ),
          ],
        );
  </code></pre>
  <p>When I run get the error:</p>
  <pre><code>package:bloc_test/src/bloc_test.dart 229:13  testBloc.&lt;fn&gt;.&lt;fn&gt;
  dart:async                                   _completeOnAsyncError
  package:bloc_test/src/bloc_test.dart         testBloc.&lt;fn&gt;.&lt;fn&gt;
  ===== asynchronous gap ===========================
  dart:async                                   _asyncThenWrapperHelper
  package:bloc_test/src/bloc_test.dart         testBloc.&lt;fn&gt;.&lt;fn&gt;
  dart:async                                   runZonedGuarded
  package:bloc_test/src/bloc_test.dart 192:13  testBloc.&lt;fn&gt;
  package:bloc_test/src/bloc_test.dart 191:5   testBloc.&lt;fn&gt;
  dart:async                                   runZoned
  package:bloc/src/bloc_overrides.dart 46:26   BlocOverrides.runZoned
  package:bloc_test/src/bloc_test.dart 190:23  testBloc
  package:bloc_test/src/bloc_test.dart 156:13  blocTest.&lt;fn&gt;
  package:bloc_test/src/bloc_test.dart 155:5   blocTest.&lt;fn&gt;
  
  Expected: [
              HomeState:HomeState(Instance of 'ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;', false),
              HomeState:HomeState(Instance of 'ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;', false)
            ]
    Actual: [
              HomeState:HomeState(Instance of 'ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;', false),
              HomeState:HomeState(Instance of 'ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;', false)
            ]
     Which: at location [0] is HomeState:&lt;HomeState(Instance of 'ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;', false)&gt; instead of HomeState:&lt;HomeState(Instance of 'ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;', false)&gt;
  
  WARNING: Please ensure state instances extend Equatable, override == and hashCode, or implement Comparable.
  Alternatively, consider using Matchers in the expect of the blocTest rather than concrete state instances.
  </code></pre>
  <p><code>repositoriesDummyEntityFromRemote</code> is <code>List&lt;RepositoriesEntity&gt;</code></p>
  <p>Please help me to solve my test. Below is my Bloc, State, and ViewData.</p>
  <p>ViewData</p>
  <pre class="lang-dart prettyprint-override"><code>class ViewData&lt;T&gt; {
    ViewState status;
    T? data;
    String message = &quot;&quot;;
    Failure? failure;
  
    ViewData._({
      required this.status,
      this.data,
      this.message = &quot;&quot;,
      this.failure,
    });
  
    factory ViewData.loaded({T? data}) {
      return ViewData._(status: ViewState.loaded, data: data);
    }
  
    factory ViewData.error({required Failure? failure}) {
      return ViewData._(status: ViewState.error, failure: failure);
    }
  
    factory ViewData.loading({required String message}) {
      return ViewData._(status: ViewState.loading, message: message);
    }
  
    factory ViewData.initial() {
      return ViewData._(status: ViewState.initial);
    }
  
    factory ViewData.empty({required String message}) {
      return ViewData._(status: ViewState.empty, message: message);
    }
  }
  </code></pre>
  <p>HomeState</p>
  <pre class="lang-dart prettyprint-override"><code>class HomeState extends Equatable {
    final ViewData&lt;List&lt;RepositoriesEntity&gt;&gt; statusRepositories;
    final bool isShowTitle;
  
    const HomeState({
      required this.statusRepositories,
      required this.isShowTitle,
    });
  
    HomeState copyWith({
      ViewData&lt;List&lt;RepositoriesEntity&gt;&gt;? statusRepositories,
      bool? isShowTitle,
    }) {
      return HomeState(
        statusRepositories: statusRepositories ?? this.statusRepositories,
        isShowTitle: isShowTitle ?? this.isShowTitle,
      );
    }
  
    @override
    List&lt;Object?&gt; get props =&gt; [statusRepositories, isShowTitle];
  }
  </code></pre>
  <p>HomeBloc</p>
  <pre class="lang-dart prettyprint-override"><code>class HomeBloc extends Bloc&lt;HomeEvent, HomeState&gt; {
    final GTHomeUseCase homeUseCase;
  
    HomeBloc({
      required this.homeUseCase,
    }) : super(HomeState(
            statusRepositories: ViewData.initial(),
            isShowTitle: false,
          )) {
      on&lt;GetRepositories&gt;(_getRepositories);
    }
  
    Future&lt;void&gt; _getRepositories(
      GetRepositories event,
      Emitter&lt;HomeState&gt; emit,
    ) async {
      emit(state.copyWith(
          statusRepositories: ViewData.loading(message: 'Loading')));
  
      final response = await homeUseCase.getRepositories();
  
      return response.fold(
        (Failure failure) =&gt; _onFailureRepositories(emit, failure),
        (List&lt;RepositoriesEntity&gt; data) =&gt; _onSuccessRepositories(emit, data),
      );
    }
  
    Future&lt;void&gt; _onFailureRepositories(
      Emitter&lt;HomeState&gt; emit,
      Failure failure,
    ) async {
      emit(state.copyWith(statusRepositories: ViewData.error(failure: failure)));
    }
  
    Future&lt;void&gt; _onSuccessRepositories(
      Emitter&lt;HomeState&gt; emit,
      List&lt;RepositoriesEntity&gt; data,
    ) async {
      emit(state.copyWith(statusRepositories: ViewData.loaded(data: data)));
      await Future.delayed(const Duration(milliseconds: 500));
      emit(state.copyWith(isShowTitle: true));
    }
  }
  </code></pre>
  <p>Anyone know how to fix my bloc so I can make it testable?</p>