performAction method

void performAction(
  1. FinderBase<SemanticsNode> finder,
  2. SemanticsAction action, {
  3. Object? args,
  4. bool checkForAction = true,
})

Performs the given SemanticsAction on the SemanticsNode found by finder.

If args are provided, they will be passed unmodified with the action. The checkForAction argument allows for attempting to perform action on node even if it doesn't report supporting that action. This is useful for implicitly supported actions such as SemanticsAction.showOnScreen.

Implementation

void performAction(
  finders.FinderBase<SemanticsNode> finder,
  SemanticsAction action, {
  Object? args,
  bool checkForAction = true
}) {
  final SemanticsNode node = finder.evaluate().single;
  if (checkForAction && !node.getSemanticsData().hasAction(action)){
    throw StateError(
      'The given node does not support $action. If the action is implicitly '
      'supported or an unsupported action is being tested for this node, '
      'set `checkForAction` to false.\n'
      'Node: $node'
    );
  }

  node.owner!.performAction(node.id, action, args);
}