Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@ class ProtocolHandlerWindows extends MethodChannelProtocolHandler {
}

@override
Future<void> register(String scheme) async {
Future<void> register(String scheme, {String? friendlyAppName}) async {
String appPath = Platform.resolvedExecutable;

String protocolRegKey = 'Software\\Classes\\$scheme';
RegistryValue protocolRegValue = const RegistryValue(
RegistryValue protocolRegValue = const RegistryValue.string(
'URL Protocol',
RegistryValueType.string,
'',
);
String protocolCmdRegKey = 'shell\\open\\command';
RegistryValue protocolCmdRegValue = RegistryValue(
RegistryValue protocolCmdRegValue = RegistryValue.string(
'',
RegistryValueType.string,
'$appPath "%1"',
);

final regKey = Registry.currentUser.createKey(protocolRegKey);
regKey.createValue(protocolRegValue);
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);

if (friendlyAppName != null) {
String applicationRegKey = 'Application';
RegistryValue friendlyAppNameRegValue = RegistryValue.string(
'ApplicationName',
friendlyAppName,
);
regKey.createKey(applicationRegKey).createValue(friendlyAppNameRegValue);
}
}
}
2 changes: 1 addition & 1 deletion packages/protocol_handler_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter
protocol_handler_platform_interface: ^0.2.0
win32_registry: ^1.0.2
win32_registry: ^2.1.0

dev_dependencies:
flutter_test:
Expand Down