'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 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 c.lamont.dev