overlayment
overlayment copied to clipboard
Position of window in OverWindow getting unnecessarily adjusted ?
I can't seem to get my Window overlays to appear where they should. It seems like the code below may be unnecessarily adjusting the position of the overlay from what is passed in the position parameter. Can you verify this and fix if you agree?
@override Future<T?> show<T>({BuildContext? context}) => Overlayment.show(this, context: context);
Offset _calcPosition(Size screen, Size? size, Offset? moveDelta) { if (moveDelta != null) return moveDelta;
if (position != null) {
if (size == null) return position!;
var xPercent = position!.dx / screen.width;
var yPercent = position!.dy / screen.height;
return Offset(
position!.dx - size.width * xPercent,
position!.dy - size.height * yPercent,
);
}
size = size ?? const Size(0, 0);
final x = (screen.width / 2 + screen.width / 2 * alignment!.x) - (size.width * 0.5 + size.width * 0.5 * alignment!.x);
final y = (screen.height / 2 + screen.height / 2 * alignment!.y) - (size.height * 0.5 + size.height * 0.5 * alignment!.y);
return Offset(x, y);
}