'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.



Solution 1:[1]

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);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1