I'm writing unit and integration tests for Flutter. If many widgets, with similar aspects (e.g. text), appear more than one time, how to filter for the right one?
Asked
Active
Viewed 1,208 times
1 Answers
2
There are several options:
Finder.first
finds the first occurrence of the widgetFinder.last
finds the last occurrence of the widgetFinder.hitTestable
finds only the widgets that can be reached by a hit test (e.g. by a tap)Finder.skipOffstage
finds only widgets considered to be "on-stage" (see Offstage widget)find.descendant
finds only widgets that are descendants of another widget
Finally you can use find.byPredicate
or even extend the Finder
class and get much more flexibility.

Yegor
- 2,931
- 1
- 17
- 6
-
For code usage of `find.descendant`, please see this answer https://stackoverflow.com/a/47296248/190309 – anticafe Jul 29 '19 at 03:43