From 2cc3a55984f5ebc7467676fc7b17494f67350cb5 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Wed, 17 Dec 2025 16:45:10 -0800 Subject: [PATCH] Add hideWindowOnStart option to app startup Introduces a new hideWindowOnStart configuration option, allowing the app window to be hidden on startup based on project settings. Passes this option to setupDesktop for improved control over window visibility during launch. --- {{cookiecutter.out_dir}}/lib/main.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.out_dir}}/lib/main.dart b/{{cookiecutter.out_dir}}/lib/main.dart index 366c691..001c97f 100644 --- a/{{cookiecutter.out_dir}}/lib/main.dart +++ b/{{cookiecutter.out_dir}}/lib/main.dart @@ -31,10 +31,14 @@ import 'package:{{ dep }}/{{ dep }}.dart' as {{ dep }}; {% set startup_screen_message = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.startup_screen.message") or get_pyproject("tool.flet.app.startup_screen.message") %} +{% set hide_window_on_start = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.hide_window_on_start") + or get_pyproject("tool.flet.app.hide_window_on_start") %} + show_boot_screen: {{ show_boot_screen }} boot_screen_message: {{ boot_screen_message }} show_startup_screen: {{ show_startup_screen }} startup_screen_message: {{ startup_screen_message }} +hide_window_on_start: {{ hide_window_on_start }} */ const bool isRelease = bool.fromEnvironment('dart.vm.product'); @@ -45,6 +49,7 @@ final showAppBootScreen = bool.tryParse("{{ show_boot_screen }}".toLowerCase()) const appBootScreenMessage = '{{ boot_screen_message | default("Preparing the app for its first launch…", true) }}'; final showAppStartupScreen = bool.tryParse("{{ show_startup_screen }}".toLowerCase()) ?? false; const appStartupScreenMessage = '{{ startup_screen_message | default("Getting things ready…", true) }}'; +final hideWindowOnStart = bool.tryParse("{{ hide_window_on_start }}".toLowerCase()) ?? false; List extensions = [ {% for dep in cookiecutter.flutter.dependencies %} @@ -127,7 +132,7 @@ Future prepareApp() async { _args.remove("--debug"); } - await setupDesktop(); + await setupDesktop(hideWindowOnStart: hideWindowOnStart); if (kIsWeb) { // web mode - connect via HTTP