findComponentOffset static method

Offset findComponentOffset(
  1. String nodeId,
  2. Alignment alignment, [
  3. Finder? finder
])

Returns the (x,y) offset for the component which renders the node with the given nodeId.

By default, this method expects a single SuperEditor in the widget tree and finds it byType. To specify one SuperEditor among many, pass a superEditorFinder.

Implementation

static Offset findComponentOffset(String nodeId, Alignment alignment, [Finder? finder]) {
  final documentLayout = findDocumentLayout(finder);
  final component = documentLayout.getComponentByNodeId(nodeId);
  assert(component != null);
  final componentBox = component!.context.findRenderObject() as RenderBox;
  final rect = componentBox.localToGlobal(Offset.zero) & componentBox.size;
  return alignment.withinRect(rect);
}