findAnchor method

Future<Anchor?> findAnchor(
  1. String anchorKeyId
)

Returns an Anchor wich contains position, size and rect of the widget containing the key.

this requires an anchorKeyId to search within our keys

Implementation

Future<Anchor?> findAnchor(String anchorKeyId) async {
  final element = _elementFinder! //
      .searchChildElementByKey(getAnchorKey(anchorKeyId));
  if (element == null || element.bounds == null) {
    debugPrint("anchor not found");
    return null;
  }
  final anchorSize = element.bounds!.size;
  final currentPos = element.offset!;
  final writeArea = _elementFinder!.getLargestAvailableSpace(element);
  return Anchor(
    size: anchorSize,
    offset: currentPos,
    rect: writeArea,
  );
}