Closed GP4cK closed 2 weeks ago
Thanks for the report! This is a known issue, at the moment you have to close databases before the test finishes to clear up the outstanding timers. Drift uses these timers to not immediately invalidate stream queries after a listener detaches (which can improve performance around common patterns like StreamBuilder
s that detach and immediately re-attach on rebuilds).
I think we should have an option to disable that behavior because this makes drift a lot harder to use in Flutter unit tests, and this optimization is not really necessary there.
That was fast! Looking forward to the next release. Thank you!
If I create a widget test that pumps a widget that is using a watch query, the test will fail with this error:
I've created a sample repo here: https://github.com/GP4cK/drift_stream_timer_issue
As a workaround, if I wrap the test with a
runAsync()
and pump a Container at the end, then it passes: