Skip to content

Commit

Permalink
wip ExactElementFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Feb 12, 2025
1 parent 5736c74 commit 869c888
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/widgets/sticky_header_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,29 @@ class TouchSlop extends StatelessWidget {
child: child);
}
}

/// Finds the widget that corresponds to the given element.
///
/// This is useful when one has an [Element]
/// (for example, from the result of another finder)
/// and wants to pass it to an API that expects a finder.
class ExactElementFinder extends FinderBase<Element> {
ExactElementFinder(this.element);

final Element element;

@override
Iterable<Element> get allCandidates => [element];

@override
String describeMatch(Plurality plurality) {
assert(plurality == Plurality.one);
return 'the given element ($element)';
}

@override
Iterable<Element> findInCandidates(Iterable<Element> candidates) {
assert(identical(candidates.single, element));
return candidates;
}
}

0 comments on commit 869c888

Please sign in to comment.