Enable debug mode if FLET_PAGE_URL provided

This commit is contained in:
Feodor Fitsner 2025-06-10 13:11:03 -07:00
parent 7174430e6f
commit 9e3d215ca8
1 changed files with 7 additions and 6 deletions

View File

@ -64,6 +64,11 @@ Map<String, String> environmentVariables = {};
void main(List<String> args) async { void main(List<String> args) async {
_args = List<String>.from(args); _args = List<String>.from(args);
var devPageUrl = const String.fromEnvironment("FLET_PAGE_URL");
if (devPageUrl != "") {
_args.addAll([devPageUrl, "--debug"]);
}
for (var ext in extensions) { for (var ext in extensions) {
ext.ensureInitialized(); ext.ensureInitialized();
} }
@ -124,7 +129,6 @@ Future prepareApp() async {
await setupDesktop(); await setupDesktop();
var devPageUrl = const String.fromEnvironment("FLET_PAGE_URL");
if (kIsWeb) { if (kIsWeb) {
// web mode - connect via HTTP // web mode - connect via HTTP
pageUrl = Uri.base.toString(); pageUrl = Uri.base.toString();
@ -132,13 +136,10 @@ Future prepareApp() async {
if (routeUrlStrategy == "path") { if (routeUrlStrategy == "path") {
setPathUrlStrategy(); setPathUrlStrategy();
} }
} else if ((_args.isNotEmpty || devPageUrl != "") && isDesktopPlatform()) { } else if (_args.isNotEmpty && isDesktopPlatform()) {
// developer mode // developer mode
debugPrint("Flet app is running in Developer mode"); debugPrint("Flet app is running in Developer mode");
pageUrl = devPageUrl; pageUrl = _args[0];
if (_args.isNotEmpty && pageUrl == "") {
pageUrl = _args[0];
}
if (_args.length > 1) { if (_args.length > 1) {
var pidFilePath = _args[1]; var pidFilePath = _args[1];
debugPrint("Args contain a path to PID file: $pidFilePath}"); debugPrint("Args contain a path to PID file: $pidFilePath}");