Home > database >  Hide Console Window in Dart on windows
Hide Console Window in Dart on windows

Time:09-16

I want to build an application with Dart in Windows. How to hide the console window when application will be start? Like a background service.

Thanks.

CodePudding user response:

It is kinda a hack where the console window will flash really quickly since the program will spawn the console window but the first line will then hide it again:

import 'package:win32/win32.dart';

void main() {
  ShowWindow(GetConsoleWindow(), SW_HIDE);
  // Your program...
}

But the rest of your program will then run in the background.

(Inspired by: https://stackoverflow.com/a/9618984/1953515)

Another ("hacky") solution could be to do what is suggested in the following where we do a change on the generated exe file from dart compile exe with editbin.exe: https://stackoverflow.com/a/2435907/1953515

  •  Tags:  
  • dart
  • Related