candidateAlignmentOffsets function
Implementation
List<Offset> candidateAlignmentOffsets({
required Offset anchorPx,
required Size size,
required Alignment currentAlignment,
required EdgeInsets margin,
required bool rotate,
required double mapRotationRad,
}) {
final base = overlayRect(
origin: anchorPx,
size: size,
alignment: currentAlignment * -1,
mapRotationRad: mapRotationRad,
rotate: rotate,
margin: margin,
);
final alignments = <Alignment>[
currentAlignment,
Alignment.topLeft,
Alignment.topRight,
Alignment.bottomLeft,
Alignment.bottomRight,
];
final offsets = <Offset>[Offset.zero];
for (final alignment in alignments) {
final rect = overlayRect(
origin: anchorPx,
size: size,
alignment: alignment * -1,
mapRotationRad: mapRotationRad,
rotate: rotate,
margin: margin,
);
final offset = rect.topLeft - base.topLeft;
final exists =
offsets.any((value) => (value - offset).distanceSquared < 0.5);
if (!exists) offsets.add(offset);
}
return offsets;
}