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

339 views Asked by At

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?.

1

There are 1 answers

0
c.lamont.dev On BEST ANSWER

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')));
  });