|
| 1 | +import 'dart:io'; |
1 | 2 | import 'dart:ui'; |
2 | 3 |
|
3 | 4 | import 'package:auto_updater/auto_updater.dart'; |
@@ -31,6 +32,8 @@ import 'package:flutter/material.dart'; |
31 | 32 | import 'package:flutter_bloc/flutter_bloc.dart'; |
32 | 33 | import 'package:go_router/go_router.dart'; |
33 | 34 | import 'package:google_fonts/google_fonts.dart'; |
| 35 | +import 'package:launch_at_startup/launch_at_startup.dart'; |
| 36 | +import 'package:package_info_plus/package_info_plus.dart'; |
34 | 37 | import 'package:shared_preferences/shared_preferences.dart'; |
35 | 38 | import 'package:window_manager/window_manager.dart'; |
36 | 39 |
|
@@ -68,6 +71,14 @@ void main() async { |
68 | 71 | autoUpdater.setFeedURL(feedURL); |
69 | 72 | autoUpdater.setScheduledCheckInterval(3600); |
70 | 73 |
|
| 74 | + packageInfo = await PackageInfo.fromPlatform(); |
| 75 | + |
| 76 | + // Launch at startup |
| 77 | + launchAtStartup.setup( |
| 78 | + appName: packageInfo.appName, |
| 79 | + appPath: Platform.resolvedExecutable, |
| 80 | + ); |
| 81 | + |
71 | 82 | // Easy localization |
72 | 83 | await EasyLocalization.ensureInitialized(); |
73 | 84 |
|
@@ -274,6 +285,13 @@ class _MyAppState extends State<MyApp> { |
274 | 285 | updateAppearanceMode(window, sharedPreferencesManager); |
275 | 286 | }; |
276 | 287 | } |
| 288 | + |
| 289 | + final isLaunchAtStartupExists = |
| 290 | + sharedPreferencesManager.isKeyExists(SharedPreferencesManager.keyIsLaunchAtStartup); |
| 291 | + if (!isLaunchAtStartupExists) { |
| 292 | + await launchAtStartup.enable(); |
| 293 | + sharedPreferencesManager.putBool(SharedPreferencesManager.keyIsLaunchAtStartup, true); |
| 294 | + } |
277 | 295 | }); |
278 | 296 | super.initState(); |
279 | 297 | } |
|
0 commit comments