tapAction static method

Future<void> tapAction(
  1. WidgetTester tester,
  2. Finder cellFinder,
  3. int actionIndex
)

Taps the action button at actionIndex in a revealed cell.

Implementation

static Future<void> tapAction(
    WidgetTester tester, Finder cellFinder, int actionIndex) async {
  final state = tester.state<SwipeActionCellState>(cellFinder);
  if (state.currentSwipeState != SwipeState.revealed) {
    fail('SwipeTester.tapAction: cell is not in revealed state '
        '(actual: ${state.currentSwipeState}). '
        'Call swipeLeft/swipeRight and pumpAndSettle first.');
  }
  final panel = find.descendant(
      of: cellFinder, matching: find.byType(SwipeActionPanel));
  final actions =
      find.descendant(of: panel, matching: find.byType(GestureDetector));
  final count = tester.widgetList(actions).length;
  if (actionIndex >= count) {
    fail('SwipeTester.tapAction: actionIndex $actionIndex exceeds '
        'available actions ($count).');
  }
  await tester.tap(actions.at(actionIndex), warnIfMissed: false);
  await tester.pumpAndSettle();
}