Use case
I'm writing an integration test for a mobile app. I tried using WidgetTester.ensureVisible() (inherited from WidgetController.ensureVisible) to scroll a widget into the viewport and then tap() it.
The scroll operation failed (#88762) and ensureVisible() failed to move the widget entirely onto the screen. It silently ignored this error. Then I wasted time trying to figure out why the subsequent tap() call failed (which also silently failed #88759).
I'm surprised to find a library from Google that silently ignores errors. I think future Flutter users would benefit from a WidgetTester rewrite that follows modern software engineering practices like "fail fast" and "fail with a useful error message". CC: @timsneath
Proposal
- Rename
ensureVisible() to tryEnsureVisible() and make it return true if it moved the widget onto the screen.
- Add a new
ensureVisible() method that immediately fails the test if it cannot move the widget onto the screen.
Use case
I'm writing an integration test for a mobile app. I tried using
WidgetTester.ensureVisible()(inherited fromWidgetController.ensureVisible) to scroll a widget into the viewport and thentap()it.The scroll operation failed (#88762) and
ensureVisible()failed to move the widget entirely onto the screen. It silently ignored this error. Then I wasted time trying to figure out why the subsequenttap()call failed (which also silently failed #88759).I'm surprised to find a library from Google that silently ignores errors. I think future Flutter users would benefit from a
WidgetTesterrewrite that follows modern software engineering practices like "fail fast" and "fail with a useful error message". CC: @timsneathProposal
ensureVisible()totryEnsureVisible()and make it returntrueif it moved the widget onto the screen.ensureVisible()method that immediately fails the test if it cannot move the widget onto the screen.