Ad

Tester.scrollUntilVisible() Not Working With GridView In Flutter Integration Testing

I am trying to scroll and find widget from the GridView in integration testing in flutter. But the code not working:

tester.scrollUntilVisible(itemFinder, -100, scrollable: gridViewFinder)

But this is not working. It is saying GridView is not scrollable.

Ad

Answer

There are few steps I made mistake here:

  1. scrollUntilVisible() is Future, so

    await tester.scrollUntilVisible(...);

  2. to scroll down, delta should be positive:

    await tester.scrollUntilVisible(itemFinder, 100.0, ...);

  3. if there is only one list in screen, I don't have to include scrollable:

    await tester.scrollUntilVisible(itemFinder, 100.0);

Now done! Final answer:

await tester.scrollUntilVisible(itemFinder, 100.0);
Ad
source: stackoverflow.com
Ad