Closed karvulf closed 2 years ago
Hi @karvulf 👋 Thanks for opening an issue!
You can use a StreamController
in this case like:
final controller = StreamController<MyState>();
whenListen(bloc, controller.stream);
await tester.pumpWidget(...);
controller.add(someState);
Hope that helps 👍
Works perfect, thank you very much @felangel
Description
Hi. I am writing a test where I want to test my
BlocListener
. The problem is that when usingwhenListen
, the specific state is emitted directly after the widget was built. This happens when I writewhenListen
first, also I don't see another way to listen to states.Desired Solution
My goal is that I want to pump my widget and afterwards, e. g. after a
pump
, I want to emit a new state to myBlocListener
. I am not sure if that's even possible.Maybe I am understanding something totally wrong but is there a way to achieve this?
Thank you for your time and help!