setBounds method

Future<void> setBounds(
  1. Rect? bounds, {
  2. Offset? position,
  3. Size? size,
  4. bool animate = false,
})

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;
  final current = window.bounds.toRect();
  final target =
      bounds ??
      Rect.fromLTWH(
        position?.dx ?? current.left,
        position?.dy ?? current.top,
        size?.width ?? current.width,
        size?.height ?? current.height,
      );
  if (!animate || !window.animateBounds(target.toNative())) {
    window.bounds = target.toNative();
  }
}