placeCaretInComponent method

Future<void> placeCaretInComponent(
  1. String nodeId,
  2. NodePosition nodePosition, {
  3. Finder? superEditorFinder,
  4. bool settle = true,
})

Implementation

Future<void> placeCaretInComponent(
  String nodeId,
  NodePosition nodePosition, {
  Finder? superEditorFinder,
  bool settle = true,
}) async {
  // Calculate the global tap position for the node position.
  final globalTapOffset = _findGlobalOffsetForPosition(nodeId, nodePosition);

  // TODO: check that the tap offset is visible within the viewport. Add option to
  // auto-scroll, or throw exception when it's not tappable.

  // Tap the desired number of times in SuperEditor at the given position.
  await tapAt(globalTapOffset);

  // Pump long enough to prevent the next tap from being seen as a sequence on top of these taps.
  await pump(kTapTimeout);

  if (settle) {
    await pumpAndSettle();
  }
}