Reputation: 1509
After building the Dart application, function Process.run starts to open a visible cmd for a second-two.
final bool checkEnvironment = environment == ShellEnvironment.powershell;
ProcessResult result = await Process.run(
checkEnvironment ? 'powershell' : command,
checkEnvironment ? [command] : args,
runInShell: checkEnvironment,
);
Link with example(gif): https://i.sstatic.net/orSzG.jpg For each command it opens a new cmd window.
If i launch the application with idea(not a build version) - such thing does not happen
Also tried this version - still the same problem:
final bool checkEnvironment = environment == ShellEnvironment.powershell;
ProcessResult result = await Process.run(
'start',
checkEnvironment ? ['/min', 'powershell', '-command', command] : ['/min', 'cmd', '/c', command],
runInShell: true,
);
Found an article that runInShell creates a new window so i removed it, but the result is still the same.
final bool checkEnvironment = environment == ShellEnvironment.powershell;
ProcessResult result = await Process.run(
checkEnvironment ? 'powershell.exe' : 'cmd',
checkEnvironment ? ['-command', command] : ['/c', command],
);
Upvotes: 1
Views: 1494
Reputation: 1509
You might have found a solution here: https://github.com/flutter/flutter/issues/47891. BUT do not use it! It does not work with window 7 and creates a problem when after closing the app user cannot delete the app due to one instance of CMD is still running.
Try this approach instead
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
CreateAndAttachConsole();
} else {
AllocConsole();
ShowWindow(GetConsoleWindow(), SW_HIDE);
}
You can replace it in windows/runner/main.cpp
Upvotes: 8