A Flutter package that makes it easy to customize and work with your Flutter desktop app window.

Overview

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 tutorial to get started. Click the image below to watch the video:

IMAGE ALT TEXT

Features:

- Custom window frame - remove standard Windows/macOS/Linux titlebar and buttons
- Hide window on startup
- Show/hide window
- Move window using Flutter widget
- Minimize/Maximize/Restore/Close window
- Set window size, minimum size and maximum size
- Set window position
- Set window alignment on screen (center/topLeft/topRight/bottomLeft/bottomRight)
- Set window title

Getting Started

Install the package using pubspec.yaml

For Windows apps

Inside your application folder, go to windows\runner\main.cpp and add these two lines at the beginning of the file:

#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);

For macOS apps

Inside your application folder, go to macos\runner\MainFlutterWindow.swift and add this line after the one saying import FlutterMacOS :

import FlutterMacOS
import bitsdojo_window_macos // Add this line

Then change this line from:

class MainFlutterWindow: NSWindow {

to this:

class MainFlutterWindow: BitsdojoWindow {

After changing NSWindow to BitsdojoWindow add these lines below the line you changed:

override func bitsdojo_window_configure() -> UInt {
  return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
}

Your code should now look like this:

class MainFlutterWindow: BitsdojoWindow {
    
  override func bitsdojo_window_configure() -> UInt {
    return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
  }
    
  override func awakeFromNib() {
    ... //rest of your code

If you don't want to use a custom frame and prefer the standard window titlebar and buttons, you can remove the BDW_CUSTOM_FRAME flag from the code above.

If you don't want to hide the window on startup, you can remove the BDW_HIDE_ON_STARTUP flag from the code above.

For Linux apps

Inside your application folder, go to linux\my_application.cc and add this line at the beginning of the file:

#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>

Then look for these two lines:

gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));

and change them to this:

auto bdw = bitsdojo_window_from(window);            // <--- add this line
bdw->setCustomFrame(true);                          // <-- add this line
//gtk_window_set_default_size(window, 1280, 720);   // <-- comment this line
gtk_widget_show(GTK_WIDGET(window));

As you can see, we commented the line calling gtk_window_set_default_size and added these two lines before gtk_widget_show(GTK_WIDGET(window));

auto bdw = bitsdojo_window_from(window);
bdw->setCustomFrame(true);

Flutter app integration

Now go to lib\main.dart and add this code in the main function right after runApp(MyApp()); :

void main() {
  runApp(MyApp());

  // Add this code below

  doWhenWindowReady(() {
    const initialSize = Size(600, 450);
    appWindow.minSize = initialSize;
    appWindow.size = initialSize;
    appWindow.alignment = Alignment.center;
    appWindow.show();
  });
}

This will set an initial size and a minimum size for your application window, center it on the screen and show it on the screen.

You can find examples in the example folder.

Here is an example that displays this window:

Click to expand
import 'package:flutter/material.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';

void main() {
  runApp(const MyApp());
  doWhenWindowReady(() {
    final win = appWindow;
    const initialSize = Size(600, 450);
    win.minSize = initialSize;
    win.size = initialSize;
    win.alignment = Alignment.center;
    win.title = "Custom window with Flutter";
    win.show();
  });
}

const borderColor = Color(0xFF805306);

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: WindowBorder(
          color: borderColor,
          width: 1,
          child: Row(
            children: const [LeftSide(), RightSide()],
          ),
        ),
      ),
    );
  }
}

const sidebarColor = Color(0xFFF6A00C);

class LeftSide extends StatelessWidget {
  const LeftSide({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return SizedBox(
        width: 200,
        child: Container(
            color: sidebarColor,
            child: Column(
              children: [
                WindowTitleBarBox(child: MoveWindow()),
                Expanded(child: Container())
              ],
            )));
  }
}

const backgroundStartColor = Color(0xFFFFD500);
const backgroundEndColor = Color(0xFFF6A00C);

class RightSide extends StatelessWidget {
  const RightSide({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [backgroundStartColor, backgroundEndColor],
              stops: [0.0, 1.0]),
        ),
        child: Column(children: [
          WindowTitleBarBox(
            child: Row(
              children: [Expanded(child: MoveWindow()), const WindowButtons()],
            ),
          )
        ]),
      ),
    );
  }
}

final buttonColors = WindowButtonColors(
    iconNormal: const Color(0xFF805306),
    mouseOver: const Color(0xFFF6A00C),
    mouseDown: const Color(0xFF805306),
    iconMouseOver: const Color(0xFF805306),
    iconMouseDown: const Color(0xFFFFD500));

final closeButtonColors = WindowButtonColors(
    mouseOver: const Color(0xFFD32F2F),
    mouseDown: const Color(0xFFB71C1C),
    iconNormal: const Color(0xFF805306),
    iconMouseOver: Colors.white);

class WindowButtons extends StatelessWidget {
  const WindowButtons({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        MinimizeWindowButton(colors: buttonColors),
        MaximizeWindowButton(colors: buttonColors),
        CloseWindowButton(colors: closeButtonColors),
      ],
    );
  }
}

❤️ Sponsors - friends helping this package

I am developing this package in my spare time and any help is appreciated.

If you want to help you can become a sponsor.

🙏 Thank you!

☕️ Coffee supporters:

Helping with a coffee every month:

Want to help? Become a sponsor

Comments
  • auto bdw = bitsdojo...--> Error waiting for a debug connection

    auto bdw = bitsdojo...--> Error waiting for a debug connection

    After Adding the line "auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);" to main.cpp of runner
    I got an error "Error waiting for a debug connection: The log reader stopped unexpectedly. Error launching application on Windows."

    I have tested the example code also

    I have checked on both Flutter DEV channel and Stable Channel

    issue

    opened by YantrabotTech 17
  • Serious problem with current Dev and Master, plugin seems broken

    Serious problem with current Dev and Master, plugin seems broken

    Hi,

    when trying to run your example with the latest flutter version on dev or master, the window never gets shown. I'm currently looking into your code but you are probably faster to find the error. I was so happy about your plugin till I upgraded Flutter grrr...

    opened by escamoteur 10
  • Build issue

    Build issue

    i'm getting build issue in master branch

    Flutter 2.10.0-1.0.pre.328 • channel master • https://github.com/flutter/flutter.git Framework • revision da88baffd7 (61 minutes ago) • 2022-01-28 16:40:12 -0800 Engine • revision 2d3663cc4d Tools • Dart 2.17.0 (build 2.17.0-67.0.dev) • DevTools 2.10.0-dev.1

    /C:/Users/SKS%20Market/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/bitsdojo_window_linux-0.1.1/lib/src/window.dart(145,19): error GCE1592F9: 'Size' is imported from both 'dart:ffi' and 'dart:ui'. [D:_sksmarket\sksmarket\build\windows\flutter\flutter_assemble.vcxproj] /C:/Users/SKS%20Market/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/bitsdojo_window_linux-0.1.1/lib/src/window.dart(153,12): error GCE1592F9: 'Size' is imported from both 'dart:ffi' and 'dart:ui'. [D:_sksmarket\sksmarket\build\windows\flutter\flutter_assemble.vcxproj]

    opened by selvam920 9
  • Windows: Rewrite WM_NCHITTEST & WM_NCCALCSIZE handling.

    Windows: Rewrite WM_NCHITTEST & WM_NCCALCSIZE handling.

    • Now resize hitbox lies outside the window frame (fixes #109 & #110).
    • Use 0 MARGINS in DwmExtendFrameIntoClientArea.
    • Removed WM_CAPTION from the parent HWND.
    • No window border is visible on Windows 10 or 11.
    • Reference: https://github.com/melak47/BorderlessWindow/issues/13.

    Windows 11

    78LbgdC6sK

    Windows 10

    harmonoid_BGzL58HNri

    Other changes:

    • I also merged Windows 7 support PR from @abutcher-gh.
    opened by alexmercerind 8
  • Window Jitter during resize on Windows 10

    Window Jitter during resize on Windows 10

    Elements are jittering when resizing the window on Window 10

    jitter

    This GIF does not represent it accurately, but you can produce it by rapidly resizing the window

    opened by geocine 7
  • converted the example folder into a fully working flutter project

    converted the example folder into a fully working flutter project

    This allows for building the plugin code (including the native C++ code) when running the example. This fixes https://github.com/bitsdojo/bitsdojo_window/issues/5

    opened by technolion 7
  • windows: portability: Support Win7 and early Win10.

    windows: portability: Support Win7 and early Win10.

    This dynamically loads the GetDpiForWindow and GetSystemMetricsForDpi to support running on Win7.

    Also, some older Win10 machines were crashing in the NCCALCSIZE handler as they were (initially) passing a null LPARAM.

    opened by abutcher-gh 6
  • can't run App in Windows 11 22H2 after add bitsdojo c++ library to main.cpp

    can't run App in Windows 11 22H2 after add bitsdojo c++ library to main.cpp

    I installed windows 11 22H2 preRelease (Build 22621.382) I realized my flutter apps doesn't run after add bitsdojo_window_plugin.h to main.cpp

    here my flutter doctor -v:

    [✓] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.22621.382], locale en-US) • Flutter version 3.0.5 at C:\Flutter\Flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2

    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\Users\Alifa\AppData\Local\Android\sdk • Platform android-33, build-tools 33.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted.

    [✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

    [✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.0) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.3.32804.467 • Windows 10 SDK version 10.0.22621.0

    [✓] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

    [✓] VS Code (version 1.70.1) • VS Code at C:\Users\Alifa\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.46.0

    [✓] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.382] • Edge (web) • edge • web-javascript • Microsoft Edge 104.0.1293.54

    [✓] HTTP Host Availability • All required HTTP hosts are available

    after run flutter run -d windows -v it completes building successfully but can't run app, after 1-2 minutes here's the error:

    [ +32 ms] Building Windows application... (completed in 108.8s) [+11229 ms] Error waiting for a debug connection: The log reader stopped unexpectedly, or never started. [ +1 ms] Error launching application on Windows. [ +3 ms] "flutter run" took 121,933ms. [ +6 ms] #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:699:9) <asynchronous suspension> #2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27) <asynchronous suspension> #3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #4 CommandRunner.runCommand (package:args/command_runner.dart:209:13) <asynchronous suspension> #5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9) <asynchronous suspension> #6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5) <asynchronous suspension> #8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9) <asynchronous suspension> #9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #10 main (package:flutter_tools/executable.dart:94:3) <asynchronous suspension> [ +254 ms] ensureAnalyticsSent: 252ms [ +4 ms] Running shutdown hooks [ +2 ms] Shutdown hooks complete [ +2 ms] exiting with code 1

    seems can't run any flutter app (debug/release) developed with bitsdojo in windows 11 22H2. Please Help! 🙏🏻

    needs more info 
    opened by Ali-Fadaei 5
  • Flutter-beta build failure: 2.11 (is next release version)

    Flutter-beta build failure: 2.11 (is next release version)

    When using 'Flutter 2.11.0-0.1.pre', the build fails at

    : Error: 'Size' is imported from both 'dart:ffi' and 'dart:ui'.
        Size sizeToSet = Size(width, height);
                         ^^^^
    

    at ../…/src/window.dart:228

    This isn't the only line failing in this file, but it seems to be limited to this file, as building for the web on this branch of beta works.

    opened by Dall127 5
  • Broken after the ^0.1.1 and ^0.1.1+1 update

    Broken after the ^0.1.1 and ^0.1.1+1 update

    Because no versions of bitsdojo_window_linux match 0.1.1 and no versions of bitsdojo_window_linux match >0.1.1 <0.2.0, bitsdojo_window_linux ^0.1.1 is forbidden. So, because my_app depends on bitsdojo_window ^0.1.1+1 which depends on bitsdojo_window_linux ^0.1.1, version solving failed. pub get failed (1; So, because my_app depends on bitsdojo_window ^0.1.1+1 which depends on bitsdojo_window_linux ^0.1.1, version solving failed.)

    opened by Shamik07 5
  • null-safety support!

    null-safety support!

    with flutter v2.0.0, Dart's sound null-safety is stable now, so for safe migrate projects to it, flutter recommended wait for migration of all project dependencies to null-safety, I have project depended on this awesome flutter plugin, please migrate it 🙏🏻

    opened by Ali-Fadaei 5
  • Crashed on Windows 11

    Crashed on Windows 11

    Windows Version: 22621.963

    My App crashes when I run it on Windows 11 with the error:

    Error waiting for a debug connection: The log reader stopped unexpectedly, or never started. 
    
    Error launching application on Windows.
    

    This does not happen on Windows 10. When I remove the added lines in /windows/runner/main.cpp the App works (but of course, without this package). When I execute the compiled .exe of my App, It works fine on Windows 10 but instantly closes on Windows 11.

    opened by 4A6F6F6E61 0
  • failed to get the app version number by https://pub.dev/packages/package_info_plus after appied the  bitsdojo_window to my windows project

    failed to get the app version number by https://pub.dev/packages/package_info_plus after appied the bitsdojo_window to my windows project

    failed to get the app version number by https://pub.dev/packages/package_info_plus

    after appied the bitsdojo_window to my windows project PackageInfo -> version is always 1.0.0 buildNumber -> buildNumber is always empty string

    opened by kstang 0
  • Possible to run widget tests against an app that is using bitsdojo_window?

    Possible to run widget tests against an app that is using bitsdojo_window?

    Very nice package - thank you for contributing it!

    I have a question. Is it possible to do widget testing (using flutter_test) on an app that incorporates bitsdojo_window? I've tried a few things, but I can't seem to figure out how to get a call to doWhenWindowReady() into my test to ensure that the app window is fully instantiated. Unsurprisingly, my test is failing miserably without it.

    Any ideas? Thanks!

    opened by john-rager 0
  • Build Error

    Build Error

    The app have been running smoothly in the development mode but when i build a release version , it only works on my computer but doesn't run on other windows machines... i tried couple of methods , but all would suggest the missing files which was already added... i decided to remove bitsdojo package and now it's working ....

    Have build release for before and after removal of the package. i can email or attach it for more details beside Kuddos for such an awesome package , it brings a lot of impossibilities to life.

    opened by shema-ryan 0
  • docs: add example with simple onGenerateRoute navigation

    docs: add example with simple onGenerateRoute navigation

    What does this PR do?

    • Moves the default example to separate folder
    • Adds an example with a simple onGenerateRoute to make it easier to use bitsdojo_window
    • Adds animations to pubspec.yaml

    Related PRs and Issues

    • #131

    Preview

    Screenshot 2022-11-19 163533

    opened by kekavc24 0
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
Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

desktop_window Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size. Usage import 'package:desktop_window/desktop_window.dart

ChunKoo Park 72 Dec 2, 2022
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
Flutter library for window blur & transparency effects for on Windows & Linux. 💙

flutter_acrylic Window blur & transparency effects for Flutter on Windows & Linux Installation Mention in your pubspec.yaml. dependencies: ... flu

Hitesh Kumar Saini 437 Dec 31, 2022
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
Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc.

Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc. And place it in the corresponding source file directory of each Flutter platform.

Dorain Gray 30 Dec 30, 2022
A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

Lucas Coelho 1 Mar 20, 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 Jan 2, 2023
Build beautiful desktop apps with flutter and rust. 🌠 (wip)

flutter-rs Build flutter desktop app in dart & rust. Get Started Install requirements Rust flutter sdk Develop install the cargo flutter command cargo

null 2k Dec 26, 2022
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
Build beautiful desktop apps with flutter and rust. 🌠

flutter-rs Build flutter desktop app in dart & rust. Get Started Install requirements Rust flutter sdk Develop install the cargo flutter command cargo

null 2k Dec 26, 2022
This plugin allows Flutter desktop apps to register and handle custom protocols

protocol_handler This plugin allows Flutter desktop apps to register and handle custom protocols (i.e. deep linking). English | 简体中文 protocol_handler

LeanFlutter 57 Dec 22, 2022
Unofficial Ubuntu Desktop Settings App made with Flutter

Unofficial Ubuntu Desktop Settings App made with Flutter - WIP The goal of this project is to build a feature complete settings app for the Ubuntu des

Frederik Feichtmeier 239 Jan 1, 2023
Create Desktop app with Flutter

Flutter Desktop Codelab Slides Créer votre première appli Desktop avec Flutter App Design Dribble YoPro Setup Linux MacOs Windows Generate executable

Flutter Togo 24 Nov 18, 2022
Ubuntu Yaru Style - Distinct look and feel of the Ubuntu Desktop

Ubuntu Yaru Style - Distinct look and feel of the Ubuntu Desktop Using Yaru To be able to use this package follow this steps: Installation Make you su

Ubuntu 226 Dec 28, 2022
An open source desktop application for creating set-plans for TV and movie productions

lyghts_desktop An open source (Windows) desktop application for creating set-plans for TV and movie productions. Getting Started This application uses

MindStudio 1 Feb 15, 2022
Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device

Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device. One of Android-Toolbox's special feature is to transfer files at the highest speed using ADB push and pull bypassing a lot of Android API overheads.

Sashank Visweshwaran 30 Dec 26, 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
This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).

hotkey_manager This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut). hotkey_manager Platform Support Quick Star

LeanFlutter 81 Dec 21, 2022