window_manager

pub version

This plugin allows Flutter desktop apps to resizing and repositioning the window.

Discord


Platform Support

LinuxmacOSWindows
✔️✔️✔️

In fact, window_manager support the web platform to integrate flutter web to web page.

See demo.

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  window_manager: ^0.0.4

Or

dependencies:
  window_manager:
    git:
      url: https://github.com/leanflutter/window_manager.git
      ref: main

Usage

Size windowSize = await WindowManager.instance.getSize();
await WindowManager.instance.setSize(Size(400, 600));
await WindowManager.instance.setAlwaysOnTop(_isAlwaysOnTop);

Please see the example app of this plugin for a full example.

Who's using it?

  • AuthPass - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3.x) compatible.
  • Biyi (比译) - A convenient translation and dictionary app written in dart / Flutter.
  • Yukino - Yukino lets you read manga or stream anime ad-free from multiple sources.

Discussion

Welcome to join the discussion group to share your suggestions and ideas with me.

API

WindowManager

MethodDescriptionLinuxmacOSWindows
setCustomFrame-✔️✔️✔️
focusFocuses on the window.✔️✔️
blurRemoves focus from the window.✔️
showShows and gives focus to the window.✔️✔️✔️
hideHides the window.✔️✔️✔️
isVisibleReturns bool - Whether the window is visible to the user.✔️✔️✔️
isMaximizedReturns bool - Whether the window is maximized.✔️✔️✔️
maximizeMaximizes the window.✔️✔️✔️
unmaximizeUnmaximizes the window.✔️✔️✔️
isMinimizedReturns bool - Whether the window is minimized.✔️✔️✔️
minimizeMinimizes the window.✔️✔️✔️
restoreRestores the window from minimized state to its previous state.✔️✔️✔️
isFullScreenReturns bool - Whether the window is in fullscreen mode.✔️✔️✔️
setFullScreenSets whether the window should be in fullscreen mode.✔️✔️✔️
setBackgroundColor-✔️✔️✔️
getBoundsReturns Rect - The bounds of the window as Object.✔️✔️✔️
setBoundsResizes and moves the window to the supplied bounds.✔️✔️✔️
getPositionReturns Offset - Contains the window's current position.✔️✔️✔️
setPositionMoves window to x and y.✔️✔️✔️
getSizeReturns Size - Contains the window's width and height.✔️✔️✔️
setSizeResizes the window to width and height.✔️✔️✔️
setMinimumSizeSets the minimum size of window to width and height.✔️✔️✔️
setMaximumSizeSets the maximum size of window to width and height.✔️✔️✔️
isResizableReturns bool - Whether the window can be manually resized by the user.✔️
setResizableSets whether the window can be manually resized by the user.✔️
isMovableReturns bool - Whether the window can be moved by user. On Linux always returns true.✔️
setMovableSets whether the window can be moved by user. On Linux does nothing.✔️
isMinimizableReturns bool - Whether the window can be manually minimized by the user. On Linux always returns true.✔️
setMinimizableSets whether the window can be manually minimized by user. On Linux does nothing.✔️
isClosableReturns bool - Whether the window can be manually closed by user. On Linux always returns true.✔️
setClosableSets whether the window can be manually closed by user. On Linux does nothing.✔️
isAlwaysOnTopReturns bool - Whether the window is always on top of other windows.✔️✔️✔️
setAlwaysOnTopSets whether the window should show always on top of other windows.✔️✔️✔️
getTitleReturns String - The title of the native window.✔️✔️✔️
setTitleChanges the title of native window to title.✔️✔️✔️
hasShadowReturns bool - Whether the window has a shadow.✔️
setHasShadowSets whether the window should have a shadow.✔️
startDragging-✔️✔️
terminate✔️✔️✔️

WindowListener

MethodDescriptionLinuxmacOSWindows
onWindowFocusEmitted when the window gains focus.✔️✔️✔️
onWindowBlurEmitted when the window loses focus.✔️✔️✔️
onWindowMaximizeEmitted when window is maximized.✔️✔️
onWindowUnmaximizeEmitted when the window exits from a maximized state.✔️
onWindowMinimizeEmitted when the window is minimized.✔️✔️✔️
onWindowRestoreEmitted when the window is restored from a minimized state.✔️✔️
onWindowEnterFullScreenEmitted when the window enters a full-screen state.✔️✔️✔️
onWindowLeaveFullScreenEmitted when the window leaves a full-screen state.✔️✔️

License

MIT License

Copyright (c) 2021 LiJianying <lijy91@foxmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Libraries

window_manager