diff --git a/lib/common/deeplink/deeplink.dart b/lib/common/deeplink/deeplink.dart new file mode 100644 index 0000000..6accc53 --- /dev/null +++ b/lib/common/deeplink/deeplink.dart @@ -0,0 +1 @@ +export 'win32.dart' if (dart.library.html) 'non_win32.dart'; diff --git a/lib/common/deeplink/non_win32.dart b/lib/common/deeplink/non_win32.dart new file mode 100644 index 0000000..bfd92db --- /dev/null +++ b/lib/common/deeplink/non_win32.dart @@ -0,0 +1 @@ +Future registerProtocol(String scheme) async {} diff --git a/lib/common/deeplink/win32.dart b/lib/common/deeplink/win32.dart new file mode 100644 index 0000000..6a678d4 --- /dev/null +++ b/lib/common/deeplink/win32.dart @@ -0,0 +1,23 @@ +import 'dart:io'; +import 'package:win32_registry/win32_registry.dart'; + +Future registerProtocol(String scheme) async { + final String appPath = Platform.resolvedExecutable; + + final String protocolRegKey = 'Software\\Classes\\$scheme'; + const RegistryValue protocolRegValue = RegistryValue( + 'URL Protocol', + RegistryValueType.string, + '', + ); + const String protocolCmdRegKey = r'shell\open\command'; + final RegistryValue protocolCmdRegValue = RegistryValue( + '', + RegistryValueType.string, + '"$appPath" "%1"', + ); + + final regKey = Registry.currentUser.createKey(protocolRegKey); + regKey.createValue(protocolRegValue); + regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue); +} diff --git a/lib/init.dart b/lib/init.dart index 17e0cba..60c6c12 100644 --- a/lib/init.dart +++ b/lib/init.dart @@ -108,24 +108,3 @@ Future _initSystemTray() async { } }); } - -Future registerProtocol(String scheme) async { - final String appPath = Platform.resolvedExecutable; - - final String protocolRegKey = 'Software\\Classes\\$scheme'; - const RegistryValue protocolRegValue = RegistryValue( - 'URL Protocol', - RegistryValueType.string, - '', - ); - const String protocolCmdRegKey = r'shell\open\command'; - final RegistryValue protocolCmdRegValue = RegistryValue( - '', - RegistryValueType.string, - '"$appPath" "%1"', - ); - - final regKey = Registry.currentUser.createKey(protocolRegKey); - regKey.createValue(protocolRegValue); - regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue); -} diff --git a/lib/main.dart b/lib/main.dart index 2873b8e..95e36c1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,7 +19,6 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_hive/sentry_hive.dart'; import 'package:system_tray/system_tray.dart'; import 'package:universal_io/io.dart'; -import 'package:win32_registry/win32_registry.dart'; import 'bloc/chesed/chesed_bloc.dart'; import 'bloc/client_setting/client_setting_bloc.dart'; @@ -30,6 +29,7 @@ import 'bloc/netzach/netzach_bloc.dart'; import 'bloc/tiphereth/tiphereth_bloc.dart'; import 'bloc/yesod/yesod_bloc.dart'; import 'common/bloc_observer.dart'; +import 'common/deeplink/deeplink.dart'; import 'common/platform.dart'; import 'consts.dart'; import 'l10n/l10n.dart';