Skip to content

Commit be02bd5

Browse files
Fix incorrect setting/checking of registry value (#10)
enable() has a bug in the case of an empty arg array. In that case an extra empty space will be added to the registry appPath value. isEnabled() has a bug in all cases, because appPath will never match the set value (due to the extra space described above).
1 parent e4d2652 commit be02bd5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/src/app_auto_launcher_impl_windows.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ import 'package:win32_registry/win32_registry.dart'
44
import 'app_auto_launcher.dart';
55

66
class AppAutoLauncherImplWindows extends AppAutoLauncher {
7+
late String _registryValue;
8+
79
AppAutoLauncherImplWindows({
810
required String appName,
911
required String appPath,
1012
List<String> args = const [],
11-
}) : super(appName: appName, appPath: appPath, args: args);
13+
}) : super(appName: appName, appPath: appPath, args: args) {
14+
_registryValue = args.isEmpty ? appPath : '$appPath ${args.join(' ')}';
15+
}
1216

1317
RegistryKey get _regKey => Registry.openPath(
1418
RegistryHive.currentUser,
@@ -19,15 +23,15 @@ class AppAutoLauncherImplWindows extends AppAutoLauncher {
1923
@override
2024
Future<bool> isEnabled() async {
2125
String? value = _regKey.getValueAsString(appName);
22-
return value == appPath;
26+
return value == _registryValue;
2327
}
2428

2529
@override
2630
Future<bool> enable() async {
2731
_regKey.createValue(RegistryValue(
2832
appName,
2933
RegistryValueType.string,
30-
'$appPath ${args.join(' ')}',
34+
_registryValue,
3135
));
3236
return true;
3337
}

0 commit comments

Comments
 (0)