toggleFinder method
Implementation
Future<void> toggleFinder(
Finder finder, {
TestStep? step,
Future<void> Function()? onBeforeToggle,
}) async {
if (finder.evaluate().isEmpty) {
throw EnsembleTestFailure('toggle: target element is detached.');
}
await tester.ensureVisible(finder);
final control = find.descendant(
of: finder,
matching: find.byWidgetPredicate(
(widget) =>
widget is Switch || widget is CupertinoSwitch || widget is Checkbox,
),
);
await _emitEvidenceBoundary(step);
await onBeforeToggle?.call();
await tester.tap(control.evaluate().isNotEmpty ? control.first : finder);
await runtime.settleAfterAction();
}