spotube/lib/collections/initializers_native.dart
IANewCool 1ecd5f6ae6 fix(web): add conditional imports for window manager and initializers
- Split wm_tools into native/web implementations
- Split initializers into native/web implementations
- Add web stubs for window management functionality
- Remove win32_registry dependency from web builds
2025-08-11 20:27:11 -04:00

27 lines
780 B
Dart

import 'dart:io';
import 'package:spotube/utils/platform.dart';
import 'package:win32_registry/win32_registry.dart';
Future<void> registerWindowsScheme(String scheme) async {
if (!kIsWindows) return;
String appPath = Platform.resolvedExecutable;
String protocolRegKey = 'Software\\Classes\\$scheme';
RegistryValue protocolRegValue = const RegistryValue(
'URL Protocol',
RegistryValueType.string,
'',
);
String protocolCmdRegKey = 'shell\\open\\command';
RegistryValue protocolCmdRegValue = RegistryValue(
'',
RegistryValueType.string,
'"$appPath" "%1"',
);
final regKey = Registry.currentUser.createKey(protocolRegKey);
regKey.createValue(protocolRegValue);
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
}