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 3
  • 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
Actor model implementation in Dart. This package makes it easier to work with isolates, create clusters of isolates.

Actor model implementation in Dart Languages: Introduction About Theater Installing What is Actor Notes about the actors Actor system Actor tree Using

Gleb Batykov 39 Nov 14, 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 346 Jan 3, 2023
Learn to build apps that work on Android, iOS, Web, and Desktop

Cross-Platform Development with Flutter Course Learn to build apps that work on Android, iOS, Web, and Desktop Go To Course Flutter is Google’s UI too

Mohamed Ibrahim 11 Oct 24, 2022
Flutter basic desktop project. Desktop todo app.

Glory Todo Desktop Basic and Primitive Flutter Desktop Project! Goal My goal is to accept my inexperience without worrying about the plugin shortcomin

Özgür 52 Dec 3, 2022
Flutter 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 438 Jan 2, 2023
Front-end of multiplayer web3 games implemented with Flutter to run on all platforms (Web, Android, iOS, Linux, Window, macOS, TV-OS)

Front-end of multiplayer web3 games implemented with Flutter to run on all platforms (Web, Android, iOS, Linux, Window, macOS, TV-OS)

R-Team 5 Nov 15, 2022
A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background which in turn increases your credit score.

Sahayog A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background whi

Utkarsh Agarwal 15 May 21, 2022
An admin panel aplication written with Flutter, aiming work with apps responsiveness.

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

Samilly Nunes 2 Oct 23, 2021
My flutter projects work with JSON

Apps work with JSON A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you star

Samandar 1 Oct 21, 2021
Worney - help people that want to know what time have been made on work time

Worney - help people that want to know what time have been made on work time

Kesse 1 Mar 10, 2022
A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority

A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority, such as a government or bank, to uphold or maintain it.

Prashant Kumar Singh 10 Dec 3, 2022
An intuitive way to work with persistent data in Dart

An intuitive way to work with persistent data in Dart. Full documentation Why Brick? Out-of-the-box offline access to data Handle and hide complex ser

Dutchie 239 Dec 26, 2022
Scaape, a first-of-its-kind social hangout app that makes organizing group hangouts with people who share similar interests as simple as shooting fish in a barrel.

Inspiration Humans are social beings, hence socializing and meeting new people is an impulsive part of our nature, but due to this recent pandemic whi

Scaape 12 Jan 10, 2022
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

Burhanuddin Rashid 1k Jan 6, 2023
A mobile image uploader in which you can upload image to your personal gallery from either your camera or mobile gallery and it can detect your current geographic location and address using firebase firestore and storage.

Image Uploader In Flutter About It is an Image Uploader gallery which tracks your address from which you're uploading using Flutter and Image picker.

Prahen parija 6 Dec 20, 2022
Starter architectures for your next Flutter project in order to make it scalable and easy for maintenance and tests.

?? ?? ?? Flutter Starter Architecture (MVVM) My custom starter project for Flutter apps. I was looking for a simple way to build Flutter app in a scal

Junior Medehou 29 Dec 25, 2022
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.

cross_connectivity A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Androi

MarchDev Toolkit 29 Nov 15, 2022
Easily scan your documents on the go with Paper. Scan those documents at ease with real-time document detection, multi paged pdfs, optimized and cleaner clicks from an easy to navigate UX

Easily scan your documents on the go with Paper. Scan those documents at ease with real-time document detection, multi paged pdfs, optimized and cleaner clicks from an easy to navigate UX

Harsh Joshi 38 Dec 16, 2022
Latest and easy-to-read news, all in your pocket 📱

Observer-flutter About Flutter app for getting live news in different categories Tools used Inshorts News API v2 This API's documentation Get the App

null 3 Jul 13, 2022