calculateOffset static method
Offset
calculateOffset({
- required AlignmentGeometry alignment,
- required double width,
- required double height,
Calculates the offset for a given alignment within a specified width and height.
Implementation
static Offset calculateOffset({
required AlignmentGeometry alignment,
required double width,
required double height,
}) {
return switch (alignment) {
(Alignment.topLeft) => Offset(width * 0.191, height * 0.191),
(Alignment.center) => Offset(width * 0.5, height * 0.5),
(Alignment.bottomRight) => Offset(width * 0.809, height * 0.809),
(Alignment.centerLeft) => Offset(width * 0.06, height * 0.5),
(Alignment.bottomCenter) => Offset(width * 0.5, height * 0.94),
(Alignment.bottomLeft) => Offset(width * 0.191, height * 0.809),
(Alignment.centerRight) => Offset(width * 0.94, height * 0.5),
(Alignment.topCenter) => Offset(width * 0.5, height * 0.06),
(Alignment.topRight) => Offset(width * 0.809, height * 0.191),
(_) => Offset(width, height),
};
}