Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

Overview

desktop_window

Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

Usage

import 'package:desktop_window/desktop_window.dart';

Future testWindowFunctions() async {
    Size size = await DesktopWindow.getWindowSize();
    print(size);
    await DesktopWindow.setWindowSize(Size(500,500));

    await DesktopWindow.setMinWindowSize(Size(400,400));
    await DesktopWindow.setMaxWindowSize(Size(800,800));

    await DesktopWindow.resetMaxWindowSize();
    await DesktopWindow.toggleFullScreen();
    bool isFullScreen = await DesktopWindow.getFullScreen();
    await DesktopWindow.setFullScreen(true);
    await DesktopWindow.setFullScreen(false);
    bool hasBorders = await DesktopWindow.hasBorders;
    await DesktopWindow.setBorders(false);
    await DesktopWindow.setBorders(true);
    await DesktopWindow.toggleBorders();
    await DesktopWindow.focus();
}

Contributers

Linux support has been contributed by Justus Fluegel (https://github.com/JustusFluegel)

Comments
  • setMinimumSize nothing works

    setMinimumSize nothing works

    // .....
    class XxxState extends State<Xxx> with WindowListener {
    @override
    void initState() {
    lazyInit();
    }
    lazyInit() async {
      windowManager.addListener(this);
      await windowManager.setMinimumSize(Size(1280, 720));  // <-- when start the app on windows, I can still resize the window to any size
    }
    }
    

    environment:

    Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 77d935af4d (4 weeks ago) • 2021-12-16 08:37:33 -0800
    Engine • revision 890a5fca2e
    Tools • Dart 2.15.1
    
    Visual Studio Community 2019 16.11.8
    Microsoft Windows [Version 10.0.19042.1110], locale zh-CN
    
    opened by sleepreading 2
  • DesktopWindow.getWindowSize() not working on Linux

    DesktopWindow.getWindowSize() not working on Linux

    Upon trying to retrieve the window size, the error "(MAINWINDOW_NOT_FOUND, GtkWindow not found, null, null)" is thrown.

    No matter where I attempt to retrieve the window size, be it on the loading of the app or by the press of a button after the window is already loaded and fully initialised, this error still occurs.

    opened by Letal1s 2
  • macOs - DesktopWindow.setMinWindowSize(Size(400,400)) not working

    macOs - DesktopWindow.setMinWindowSize(Size(400,400)) not working

    After setting this, I am still able to make the desktop macOs app smaller than 400x400 in width and height.

    Is there something additional that I need to perform apart from DesktopWindow.setMinWindowSize() to not let it be smaller than what I am setting in the width and height here?

    opened by Najib90 1
  • macos -> GeneratedPluginRegistrant: No such module 'desktop_window'

    macos -> GeneratedPluginRegistrant: No such module 'desktop_window'

    Hello, In macOS, there is a problem where the generated file from flutter is throwing an error. Although the program runs fine when using 'flutter run' when trying a native build from XCode an error is immediately thrown and is picked up as a compiler error.

    If anyone knows the solution to this problem please let me know.

    Thanks, Rhino Inani

    A screenshot of the problem is shown below.

    image

    opened by RhinoInani 1
  • Cleanup Code

    Cleanup Code

    Code cleanup in general & fix my linux mess, please merge only after testing in #18, I will merge the changes after testing there here

    Closes #9 Closes #14

    opened by JustusFluegel 1
  • Add support for borderless windows, Closes #15

    Add support for borderless windows, Closes #15

    Add support for for moving titlebar & borders of the window. I've tested my code on linux but I don't have a ~~windows or~~ macos buildchain available, so please someone test & fix it for me, I tried to get the correct code from the docs.

    Closes #15

    Edit: tested on Windows 26/06/2021 and fixed, works now

    opened by JustusFluegel 0
  • No implementation found for method setMinWindowSize on channel desktop_window

    No implementation found for method setMinWindowSize on channel desktop_window

    [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method setMinWindowSize on channel desktop_window)

    How to solve this problem?

    opened by shellrean 0
  • Add support for bringing window to front (activating window).

    Add support for bringing window to front (activating window).

    At the moment, there is no way to bring the application window to the front of the screen or activate the window using this plugin. To my knowledge (at least on macOS), calling setWindowSize asynchronously may cause the app to crash due to NSApplication.shared.mainWindow being nil when the window is out of focus.

    I've already implemented this for macOS in a separate plugin, but it would be very fitting to add support for all the platforms here in one unified plugin.

    opened by wilsonowilson 0
  • This plugin did not work on windows 11.

    This plugin did not work on windows 11.

    I tried to add some code like the following in my main.dart.

      if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
        var size = Size(config.windowWidth, config.windowHeight);
        // disable window resizing
        await DesktopWindow.setWindowSize(size);
        await DesktopWindow.setMinWindowSize(size);
        await DesktopWindow.setMaxWindowSize(size);
      }
    

    However, I got no response on windows 11, I have tested it ok on windows 10. If I comment these pieces of code or change it to use window_size of github.com/google/flutter-desktop-embedding, it works too.

    https://user-images.githubusercontent.com/2276718/137615433-75a18ab6-92df-44f8-a3f1-a6a20afbb511.mp4

    opened by liudonghua123 3
  •  can't set window size

    can't set window size

    ] Unhandled Exception: MissingPluginException(No implementation found for method setMinWindowSize on channel desktop_window) #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7) #1 DesktopWindow.setMinWindowSize (package:desktop_window/desktop_window.dart:25:12) #2 main (package:war_simulator_editor/main.dart:33:3)

    opened by Sevencats 0
  • [Linux] Fix memory leaks

    [Linux] Fix memory leaks

    • Use g_autoptr for fl_value_new_xxx() (g_malloc0()).
    • Replace fl_value_lookup() + fl_value_new_string() with fl_value_lookup_string() that takes care of allocating and releasing the string.
    opened by jpnurmi 0
  • [LINUX] Onscreen Keyboard automatically close on full screen

    [LINUX] Onscreen Keyboard automatically close on full screen

    In Linux on-screen keyboard enabled, and desktop-window set to fullscreen, the onscreen keyboard open and close automatically when I click a text filed, it's stay in normal screen.

    normal mode (without fullscreen) is working without any issue.

    opened by mjafartp 0
Owner
ChunKoo Park
ChunKoo Park
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Woodemi Co., Ltd 39 Oct 1, 2022
File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Miguel Ruivo 987 Jan 6, 2023
Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.

go-flutter - A package that brings Flutter to the desktop Purpose Flutter allows you to build beautiful native apps on iOS and Android from a single c

null 5.5k Jan 6, 2023
🎞 Flutter media playback, broadcast & recording library for Windows, Linux & macOS. Written in C++ using libVLC & libVLC++. (Both audio & video)

dart_vlc Flutter media playback, broadcast, recording & chromecast library for Windows, Linux & macOS. Written in C++ using libVLC & libVLC++. Install

Hitesh Kumar Saini 417 Dec 29, 2022
A simple-to-use flutter update package for Windows, MacOS, and Linux.

Updat - The simple-to-use, flutter-based desktop update package Updat is a simple-to-use reliable flutter-native updater that handles your application

Eduardo M. 14 Dec 21, 2022
A cross-platform app ecosystem, bringing iMessage to Android, PC (Windows, Linux, & even macOS), and Web!

BlueBubbles Android App BlueBubbles is an open-source and cross-platform ecosystem of apps aimed to bring iMessage to Android, Windows, Linux, and mor

BlueBubbles 318 Jan 8, 2023
TinyPNG4Flutter - A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS and windows

TinyPNG4Flutter A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS

逸风 20 Dec 8, 2022
An 🎵 audio playback library for Flutter Desktop. Supports Windows & Linux. Based on miniaudio.

✒ libwinmedia is sequel to this project. It provides network playback, better format support, control & features. An audio playback library for Flutte

Hitesh Kumar Saini 50 Oct 31, 2022
This plugin allows Flutter desktop apps to resizing and repositioning the window.

window_manager This plugin allows Flutter desktop apps to resizing and repositioning the window. window_manager Platform Support Quick Start Installat

LeanFlutter 351 Jan 7, 2023
A package which provides most of the window decorations from linux themes.

Window Decorations A package which provides most of the window decorations from linux themes. Features Easier to use and implement Native looking wind

Prateek SU 20 Dec 21, 2022
A cross-platform (Windows/macOS) scanner plugin for Flutter

quick_scanner A cross-platform (Windows/macOS) scanner plugin for Flutter Usage QuickScanner.startWatch(); var _scanners = await QuickScanner.getScan

Woodemi Co., Ltd 5 Jun 10, 2022
This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.

screen_retriever This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc. screen_retriever P

LeanFlutter 27 Dec 6, 2022
A Flutter plugin to read 🔖 metadata of 🎵 media files. Supports Windows, Linux & Android.

flutter_media_metadata A Flutter plugin to read metadata of media files. A part of Harmonoid open source project ?? Install Add in your pubspec.yaml.

Harmonoid 60 Dec 2, 2022
A Flutter package that makes it easy to customize and work with your Flutter desktop app window.

bitsdojo_window A Flutter package that makes it easy to customize and work with your Flutter desktop app window on Windows, macOS and Linux. Watch the

Bits Dojo 607 Jan 4, 2023
🎵 A cross-platform media playback library for C/C++ with good number of features (only Windows & Linux).

libwinmedia A cross-platform media playback library for C/C++ & Flutter with good number of features. Example A very simple example can be as follows.

Harmonoid 38 Nov 2, 2022
A pure Dart implementation of Firebase with initial support aimed at FlutterFire for Linux & Windows.

FlutterFire Desktop A work in progress pure Dart implementation of Firebase with initial support aimed at FlutterFire for Linux & Windows. A FlutterFi

Invertase 293 Jan 4, 2023
Simple file explorer for desktop made with Flutter, highly inspired by macOS Finder

file_explorer A basic file explorer made with Flutter Getting Started This project is a starting point for a Flutter application. A few resources to g

Valentin 0 Nov 7, 2021
Flutter date range pickers use a dialog window to select a range of date on mobile.

[Deprecated] Date Range Picker Currently Flutter has supported date range picker, so I think my mission is done. Thanks for using my lib. Link: https:

null 225 Dec 28, 2022
A macOS plugin which can register a callback for a global keyboard shortcut.

global_shortcuts A macOS plugin which can register a callback for a global keyboard shortcut. As the shortcut is global, the callback will be triggere

James Leahy 7 Jan 2, 2023