Rewrite setupDesktop
This commit is contained in:
parent
ec21885285
commit
6bf606da13
|
|
@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
|
|||
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||
import 'package:serious_python/serious_python.dart';
|
||||
import 'package:url_strategy/url_strategy.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
{% for dep in cookiecutter.flutter.dependencies %}
|
||||
import 'package:{{ dep }}/{{ dep }}.dart' as {{ dep }};
|
||||
|
|
@ -346,3 +347,28 @@ Future<int> getUnusedPort() {
|
|||
return port;
|
||||
});
|
||||
}
|
||||
|
||||
bool isDesktop() {
|
||||
return !kIsWeb &&
|
||||
(defaultTargetPlatform == TargetPlatform.windows ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS ||
|
||||
defaultTargetPlatform == TargetPlatform.linux);
|
||||
}
|
||||
|
||||
Future setupDesktop() async {
|
||||
if (isDesktop()) {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await windowManager.ensureInitialized();
|
||||
|
||||
Map<String, String> env = Platform.environment;
|
||||
var hideWindowOnStart = env["FLET_HIDE_WINDOW_ON_START"];
|
||||
debugPrint("hideWindowOnStart: $hideWindowOnStart");
|
||||
|
||||
await windowManager.waitUntilReadyToShow(null, () async {
|
||||
if (hideWindowOnStart == null) {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ dependencies:
|
|||
dependency_overrides:
|
||||
wakelock_plus: ^1.2.5
|
||||
web: ^1.0.0
|
||||
window_manager: ^0.4.3
|
||||
|
||||
# {% if 'flet_audio_recorder' in cookiecutter.flutter.dependencies %}
|
||||
record: ^5.1.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue