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
Flutter Widget Quiz, made for Flutter Create (Source code size is limited to 5KB)

widget_quiz The branch for Flutter Create: https://github.com/mono0926/widget-quiz/tree/5k Getting Started This project is a starting point for a Flut

Masayuki Ono (mono) 50 Oct 14, 2022
On making this project I learned using Getx to change between dark mode to light mode, learned about the time zone and schedule notification , That I have Integrated in this small app, This is the small section of making a todo app.

On making this project I learned using Getx to change between dark mode to light mode, learned about the time zone and schedule notification , That I have Integrated in this small app, This is the small section of making a todo app.

Pawan Kumar 1 Aug 22, 2022
Shopping app for small company. note : the name will change

nbb A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is y

Sadra Galavani 0 Jan 10, 2022
Attempt to implement better scrolling for Flutter Web and Desktop. Includes keyboard, MButton and custom mouse wheel scrolling.

An attempt to implement better scrolling for Flutter Web and Desktop. Includes keyboard, MButton and custom mouse wheel scrolling. Getting started Exa

Adrian Flutur 46 Jan 3, 2023
Mobile and Desktop whatsapp clone with Flutter UI tool kit

Mobile and Desktop whatsapp clone with Flutter UI tool kit

Travis Okonicha 10 Oct 25, 2022
A platform adaptive Flutter app for desktop, mobile and web.

Flutter Folio A demo app showcasing how Flutter can deliver a great multi-platform experience, targeting iOS, Android, MacOS, Windows, Linux, and web.

gskinner team 3.5k Dec 28, 2022
Web + mobile + desktop

SwiggyUI SwiggyUI App is a UI clone of a famous food ordering app called Swiggy built using Flutter. Show some ❤️ and star ⭐ the repo if you liked it,

Rudresh 28 Dec 25, 2022
Flutter Music Player - First Open Source Flutter based material design music player with audio plugin to play local music files.

Flutter Music Player First Open Source Flutter based Beautiful Material Design Music Player(Online Radio will be added soon.) Demo App Play Store BETA

Pawan Kumar 1.5k Jan 2, 2023
A flutter plugin for integrating Mobile Money Payments to your flutter apps

Add Mobile Money payments to your flutter apps using the FlutterWave api gateway. Features Recieve Payments through Mobile Money in Uganda Supports MT

null 5 Nov 9, 2022
Flutter OSM - OSM Plugin For Flutter Apps

flutter_osm_plugin osm plugin for flutter apps (only Android for now, iOS will b

null 1 Mar 29, 2022
Flute Music Player - First Open Source Flutter based material design music player with audio plugin to play local music files.

Flute Music Player Plugin Only Updated to androidx First Open Source Flutter based material design music player with audio plugin to play local music

Pawan Kumar 316 Nov 23, 2022
A two screen video call app built with flutter with the help of jitsi plugin

flutter_video_call A new Flutter application. Getting Started This project is a starting point for a Flutter application.

Success Charles 28 Oct 17, 2022
A Flutter plugin to select, open, choose, pick and create documents, images videos

file_picker_cross The only Flutter plugin to select, open, choose, pick and create documents, images videos or other files on Android, iOS, the deskto

null 0 Oct 30, 2021
Flutter Responsive Game of Thrones Flutter App Flutter Responsive Game of Thrones Flutter App

got_2019 A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Pawan Kumar 16 Jun 9, 2022
Flutter RxDart Explained - The Flutter Way Flutter RxDart Explained - The Flutter Way

rx_demo A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Pawan Kumar 27 Oct 13, 2021
Flutter social button - A flutter package to create social media login buttons easily to any flutter app

Flutter Social Button is a flutter package to create social media login buttons easily to any flutter app.

Alok Dubey 10 Dec 5, 2022
Flutter Gender Prediction App Flutter Gender Prediction App

gender_predictor A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Pawan Kumar 30 May 31, 2022
Beautiful Nike Web Design Concept With Flutter Beautiful Nike Web Design Concept With Flutter

flutter_web_nike A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Pawan Kumar 23 Jan 28, 2022