6

I've made a simple flutter app for windows, when I run it shows the default Titlebar that windows has. How can I remove it ??

nvoigt
  • 75,013
  • 26
  • 93
  • 142
Manan Domadiya
  • 119
  • 1
  • 6

2 Answers2

9

Use this package window_manager and do this.

Add this line to the top of the file:

import 'package:window_manager/window_manager.dart';

Then add this line of code(this function is not officially documented).

void main() async{
  runApp(const MyApp());
  windowManager.waitUntilReadyToShow().then((_) async{
      await windowManager.setAsFrameless();
  });
}

You may alternatively want just to hide the titlebar but leave the buttons visible. This can be done as follows:

await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
Sean O'Neil
  • 1,222
  • 12
  • 22
slatieee
  • 91
  • 1
  • 1
5

Using this package bitsdojo_window do the following:

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);

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(() {
    appWindow.show();
  });
}

You can also customize the window with something like:

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

To implement your own title buttons and text, you can use these methods from the package:

appWindow.title(title);
appWindow.close();
appWindow.maximize();
appWindow.minimize();

You can also give the properties of the title bar to any widget (like dragging and double click for maximize) by wraping it inside MoveWindow() widget.