I have a flutter bloc_test which is failing due to recent upgrades in Flutter involving null safety.
I have the following code
blocTest('get the usecase name',
build: () {
when(() => mockGetUseCaseName(any()))
.thenAnswer((_) async => Right(name));
return bloc;
},
act: (bloc) => bloc.add(GetUseCaseName(name)),
verify: (_) => verify(
() => mockGetUseCaseName(Params(string: name))));
And I get the error on the line "bloc.add"
"The method 'add' can't be unconditionally invoked because the receiver can be 'null'"
Any ideas?
the most correct solution would be to make the data type explicit
Before:
after: