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.firstfinds the first occurrence of the widgetFinder.lastfinds the last occurrence of the widgetFinder.hitTestablefinds only the widgets that can be reached by a hit test (e.g. by a tap)Finder.skipOffstagefinds only widgets considered to be "on-stage" (see Offstage widget)find.descendantfinds 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