I have tried flutter Windows Desktop application, but I am not able hide title bar to run app in full screen mode windows
8 Answers
I guess window_manager can achieve your needs
Installation
Add this to your package's pubspec.yaml file:
dependencies:
window_manager: ^0.2.7
Usage
// Enter fullscreen
await WindowManager.instance.setFullScreen(true);
// Level fullscreen
await WindowManager.instance.setFullScreen(false);
-
1It's the perfect one as of now – Rajesh Nov 08 '21 at 04:53
-
1It's on pub.dev now, so no need to pull from the git repository anymore. – FourtyTwo Oct 06 '22 at 05:15
-
https://pub.dev/packages/window_manager – TiyebM Apr 10 '23 at 10:59
Got the same problem and I'm here to share my solution.
I'm not a Win32 developer but I managed to make a basic fullscreen this way.
This code works for my Flutter version 1.21.0-10.0.pre.114, I hope it will for you too.
My solution is heavily inspired by this one : https://stackoverflow.com/a/2416613/14093885
You have to edit ./windows/runner/main.cpp
Insert the following code between these statements around line 30:
window.SetQuitOnClose(true);
//Insert Code Here
run_loop.Run();
Code to insert :
//HWND is window handler
HWND hwnd = window.GetHandle();
auto windowHDC = GetDC(hwnd);
int fullscreenWidth = GetDeviceCaps(windowHDC, DESKTOPHORZRES);
int fullscreenHeight = GetDeviceCaps(windowHDC, DESKTOPVERTRES);
int colourBits = GetDeviceCaps(windowHDC, BITSPIXEL);
int refreshRate = GetDeviceCaps(windowHDC, VREFRESH);
DEVMODE fullscreenSettings;
bool isChangeSuccessful;
EnumDisplaySettings(NULL, 0, &fullscreenSettings);
fullscreenSettings.dmPelsWidth = fullscreenWidth;
fullscreenSettings.dmPelsHeight = fullscreenHeight;
fullscreenSettings.dmBitsPerPel = colourBits;
fullscreenSettings.dmDisplayFrequency = refreshRate;
fullscreenSettings.dmFields = DM_PELSWIDTH |
DM_PELSHEIGHT |
DM_BITSPERPEL |
DM_DISPLAYFREQUENCY;
SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST);
SetWindowLongPtr(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, fullscreenWidth, fullscreenHeight, SWP_SHOWWINDOW);
isChangeSuccessful = ChangeDisplaySettings(&fullscreenSettings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL;
ShowWindow(hwnd, SW_MAXIMIZE);
EDIT - Flutter 2:
According to @Pavel the last line ShowWindow(hwnd, SW_MAXIMIZE);
is not needed in Flutter 2.

- 469
- 5
- 10
-
The flutter emulator freezes when I try this. Are you sure it's just a matter of pasting that code in? – Tunnelvisie Mar 14 '21 at 12:14
-
I'm not sure about it depending on the version of flutter your using. If it's the one I was using that should work but I would not be surprised to learn that it changed with flutter 2.0. If you are using the good `window` that should be okay I think. Anyway I am not a win32 dev so if that's not it my method probably is outdated. – Luxariox Mar 15 '21 at 13:15
-
@Tunnelvisie if you are using Flutter 2, remove this line: `ShowWindow(hwnd, SW_MAXIMIZE);` – Pavel Jun 27 '21 at 15:29
Use this package: https://github.com/leanflutter/window_manager
In your main, add this code after 'RunApp':
WidgetsFlutterBinding.ensureInitialized();
// Must add this line.
await windowManager.ensureInitialized();
// Use it only after calling `hiddenWindowAtLaunch`
windowManager.waitUntilReadyToShow().then((_) async {
// Hide window title bar
await windowManager.setTitleBarStyle('hidden');
await windowManager.setFullScreen(true);
await windowManager.center();
await windowManager.show();
await windowManager.setSkipTaskbar(false);
});

- 562
- 5
- 12
I think it must change the cpp file now.
win32_window.cpp replace "WS_OVERLAPPEDWINDOW" with "WS_POPUP | WS_MAXIMIZE"
/* WS_POPUP : without title bar WS_MAXIMIZE : full screen */

- 21
- 1
There is no built-in support for full-screen mode yet, so there's no Dart API you can call to enter full screen. If you are familiar with Win32 programming, you could either change the Runner code directly to make the window full screen, or write a plug-in that does it.

- 20,228
- 3
- 47
- 55
You need to implement the plugin window_size: https://github.com/google/flutter-desktop-embedding/tree/master/plugins/window_size
@override initState() {
super.initState();
Future.delayed(Duration.zero).then((finish) async {
if (Platform.isMacOS) {
// * FULL SCREEN
PlatformWindow window = await getWindowInfo();
setWindowFrame(Rect.fromLTWH(0, 0, window.screen.frame.width, window.screen.frame.height));
}
});
}

- 95
- 1
- 6
-
3That code will give you a decorated window that's the size of the screen. There will still be a title bar, resize handle, menu bar, etc. That's not the same as full screen mode. – smorgan Nov 30 '19 at 03:23
this is the link for more help window Size I have Done this in this way I get window size from here: https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles
in flutter windows app for window size : go to windows/runner/win32_window.cpp
- for fullscreen window without titlebar WS_POPUP | WS_VISIBLE
- for fullscreen window with titlebar(without any icon such as close,minimize,restore,logo) WS_MAXIMIZE | WS_VISIBLE
- for small or customized window WS_OVERLAPPEDWINDOW | WS_VISIBLE
- for fullscreen window with titlebar WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | WS_VISIBLE
Find this CODE given below in win32_window.cpp file and change as you wish.
HWND window = CreateWindow(
window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | WS_VISIBLE,
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
nullptr, nullptr, GetModuleHandle(nullptr), this);

- 64
- 5
I had a similar problem, but I wanted only a popup window to be full screen, not the whole app. So I needed a solution that worked together with the desktop_multi_window plugin - that's why I couldn't use the window_manager plugin which was suggested in other answers.
Windows
Open windows/runner/flutter_window.cpp
Add the include #include "desktop_multi_window/desktop_multi_window_plugin.h"
at the start of the file, below the other includes
Search for the line containing RegisterPlugins
and add the following code right below that line:
DesktopMultiWindowSetWindowCreatedCallback([](void *controller) {
auto *flutter_view_controller = reinterpret_cast<flutter::FlutterViewController *>(controller);
if (flutter_view_controller->view() != nullptr) {
HWND subHwnd = flutter_view_controller->view()->GetNativeWindow();
HWND hwnd = GetParent(subHwnd);
if (hwnd != nullptr) {
DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
MONITORINFO mi = { sizeof(mi) };
if (GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &mi)) {
SetWindowLong(hwnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
SetWindowPos(hwnd, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
}
}
});
Now every new window you create with the desktop_multi_window plugin will be shown in full screen.
I know the question was specific for Windows, but since Flutter works on all platforms you might also want to support the full screen mode in macOS and Linux.
macOS
Open macos/Runner/MainFlutterWindow.swift
Add the import import desktop_multi_window
at the start of the file, below the other imports
Search for the line containing RegisterGeneratedPlugins
and add the following code right below that line:
FlutterMultiWindowPlugin.setOnWindowCreatedCallback { controller in
controller.view.window?.toggleFullScreen(self)
}
Linux
Open linux/my_application.cc
Add the include #include "desktop_multi_window/desktop_multi_window_plugin.h"
at the start of the file, below the other includes
Search for the line containing fl_register_plugins
and add the following code right below that line:
desktop_multi_window_plugin_set_window_created_callback([](FlPluginRegistry* registry){
g_autoptr(FlPluginRegistrar) registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopMultiWindowPlugin");
FlView* view = fl_plugin_registrar_get_view(registrar);
if (view != nullptr) {
gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))));
}
});

- 1,285
- 21
- 28