FirstWhere doesn't complete even though test returns true #47637
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
closed-duplicate
Closed in favor of an existing report
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
I am trying to write a flutter app that makes fairly extensive use of Streams and Futures as it retrieves data over bluetooth.
I have a Stream that I create with an async * function by mutating another stream. I want to get the first element of this stream that matches some critera so I use firstWhere which should complete a Future when the condition is met.
Although the condition function returns true, the Future doesn't complete until the next element is processed by the stream.
I've written this example to demonstrate what I mean:
https://dartpad.dev/12ae241a54f567cea44b53fc7e1c7412
This doesn't occur when using the underlying stream directly however.
(replace line 4 with
packetStream.where(testPacket).listen((packet) => print("$packet Matches!"));
)Output of "dart --version":
Although as you can see this also occurs on DartPad.
Is there a way around this as the behaviour seems counterintuitive?
The text was updated successfully, but these errors were encountered: