Search code examples
flutterblocbloc-test

Flutter blocTest Missing type arguments for generic function 'blocTest<B extends BlocBase<State>, State>'


When following the bloc test documentation, I created the following blocTest;

blocTest('should do something',
    build: () => SignInBloc(signIn: mockSignIn),
    act: (bloc) => bloc.add(const OnEmailChanged(email: 'test')));

However I get the intellisense error;

Missing type arguments for generic function 'blocTest<B extends BlocBase<State>, State>'.

And the (bloc) provided in the add is of type Object?.


Solution

  • To fix the issue you have to tell the blocTest what types to expect.

    blocTest<SignInBloc, SignInState>('should do something',
        build: () => SignInBloc(signIn: mockSignIn),
        act: (bloc) => bloc.add(const OnEmailChanged(email: 'test')));
      });