findAnchor method
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, {
HelperAlignment? align,
}) 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!;
if (align != null) {
return Anchor(
size: anchorSize,
offset: currentPos,
rect: _elementFinder!.getSpaceFromAlignment(align, element),
);
}
return Anchor(
size: anchorSize,
offset: currentPos,
rect: _elementFinder!.getLargestAvailableSpace(element),
);
}