1e97716636
plugins/window replaces the window_manager fork on every desktop. Changelog: Tray hotkeys, node delays and a delay test
51 lines
1.0 KiB
Dart
51 lines
1.0 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:launch_at_startup/launch_at_startup.dart';
|
|
|
|
import 'constant.dart';
|
|
import 'system.dart';
|
|
|
|
class AutoLaunch {
|
|
static AutoLaunch? _instance;
|
|
|
|
AutoLaunch._internal() {
|
|
launcher.setup(appName: appName, appPath: Platform.resolvedExecutable);
|
|
}
|
|
|
|
factory AutoLaunch() {
|
|
_instance ??= AutoLaunch._internal();
|
|
return _instance!;
|
|
}
|
|
|
|
@visibleForTesting
|
|
static LaunchAtStartup launcher = launchAtStartup;
|
|
|
|
Future<bool> get isEnable async {
|
|
return launcher.isEnabled();
|
|
}
|
|
|
|
Future<bool> enable() async {
|
|
return launcher.enable();
|
|
}
|
|
|
|
Future<bool> disable() async {
|
|
return launcher.disable();
|
|
}
|
|
|
|
Future<void> updateStatus(bool isAutoLaunch) async {
|
|
if (kDebugMode) {
|
|
return;
|
|
}
|
|
if (await isEnable == isAutoLaunch) return;
|
|
if (isAutoLaunch == true) {
|
|
unawaited(enable());
|
|
} else {
|
|
unawaited(disable());
|
|
}
|
|
}
|
|
}
|
|
|
|
final autoLaunch = system.isDesktop && !safeModeBuild ? AutoLaunch() : null;
|