ancestor method
- required FinderBase<
Element> of, - required FinderBase<
Element> matching, - bool matchRoot = false,
 
Finds widgets that are ancestors of the of parameter and that match
the matching parameter.
Sample code
// Test if a Text widget that contains 'faded' is the
// descendant of an Opacity widget with opacity 0.5:
expect(
  tester.widget<Opacity>(
    find.ancestor(
      of: find.text('faded'),
      matching: find.byType(Opacity),
    )
  ).opacity,
  0.5
);
If the matchRoot argument is true then the widget(s) specified by of
will be matched along with the ancestors.
Implementation
Finder ancestor({
  required FinderBase<Element> of,
  required FinderBase<Element> matching,
  bool matchRoot = false,
}) {
  return _AncestorWidgetFinder(of, matching, matchLeaves: matchRoot);
}