setBounds method
Resizes and moves the window to the supplied bounds.
Implementation
Future<void> setBounds(
Rect? bounds, {
Offset? position,
Size? size,
bool animate = false,
}) async {
final window = _target;
if (window == null) return;
if (bounds == null && position == null && size == null) return;
// Write only the requested component for partial updates: asynchronous
// window managers (such as X11) can still report the old bounds after a
// recent resize or move, and writing back a full frame would clobber it.
if (bounds == null && position == null && size != null) {
window.setSize(size.toNative(), animate);
return;
}
if (bounds == null && size == null && position != null) {
if (animate) {
final current = window.bounds.toRect();
final target = Rect.fromLTWH(
position.dx,
position.dy,
current.width,
current.height,
);
if (window.animateBounds(target.toNative())) return;
}
window.position = position.toNative();
return;
}
final target =
bounds ??
Rect.fromLTWH(position!.dx, position.dy, size!.width, size.height);
if (!animate || !window.animateBounds(target.toNative())) {
window.bounds = target.toNative();
}
}