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
153 changes: 153 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "protocol_handler",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler",
"cwd": "packages\\protocol_handler",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler (profile mode)",
"cwd": "packages\\protocol_handler",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "protocol_handler (release mode)",
"cwd": "packages\\protocol_handler",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "protocol_handler_android",
"cwd": "packages\\protocol_handler_android",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler_android (profile mode)",
"cwd": "packages\\protocol_handler_android",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "protocol_handler_android (release mode)",
"cwd": "packages\\protocol_handler_android",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "protocol_handler_ios",
"cwd": "packages\\protocol_handler_ios",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler_ios (profile mode)",
"cwd": "packages\\protocol_handler_ios",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "protocol_handler_ios (release mode)",
"cwd": "packages\\protocol_handler_ios",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "protocol_handler_macos",
"cwd": "packages\\protocol_handler_macos",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler_macos (profile mode)",
"cwd": "packages\\protocol_handler_macos",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "protocol_handler_macos (release mode)",
"cwd": "packages\\protocol_handler_macos",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "protocol_handler_platform_interface",
"cwd": "packages\\protocol_handler_platform_interface",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler_platform_interface (profile mode)",
"cwd": "packages\\protocol_handler_platform_interface",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "protocol_handler_platform_interface (release mode)",
"cwd": "packages\\protocol_handler_platform_interface",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "protocol_handler_windows",
"cwd": "packages\\protocol_handler_windows",
"request": "launch",
"type": "dart"
},
{
"name": "protocol_handler_windows (profile mode)",
"cwd": "packages\\protocol_handler_windows",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "protocol_handler_windows (release mode)",
"cwd": "packages\\protocol_handler_windows",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "example",
"cwd": "packages\\protocol_handler\\example",
"request": "launch",
"type": "dart"
},
{
"name": "example (profile mode)",
"cwd": "packages\\protocol_handler\\example",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "example (release mode)",
"cwd": "packages\\protocol_handler\\example",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library protocol_handler_windows;

export 'src/protocol_handler_windows.dart';
export 'src/protocol_handler_windows_impl.dart';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:protocol_handler_platform_interface/protocol_handler_platform_interface.dart';

abstract class ProtocolHandlerWindowsBase extends MethodChannelProtocolHandler {
Future<void> register(String scheme, {String? friendlyAppName});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:protocol_handler_platform_interface/protocol_handler_platform_interface.dart';

import 'protocol_handler_windows_stub.dart'
if (dart.library.io) 'protocol_handler_windows_io.dart'
if (dart.library.html) 'protocol_handler_windows_web.dart';

class ProtocolHandlerWindows extends MethodChannelProtocolHandler {
final ProtocolHandlerWindowsImpl _impl;

ProtocolHandlerWindows() : _impl = ProtocolHandlerWindowsImpl();

static void registerWith() {
ProtocolHandlerPlatform.instance = ProtocolHandlerWindowsImpl();
}

Future<void> register(String scheme, {String? friendlyAppName}) async {
return await _impl.register(
scheme,
friendlyAppName: friendlyAppName,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'dart:io';

import 'package:protocol_handler_platform_interface/protocol_handler_platform_interface.dart';
import 'package:protocol_handler_windows/src/protocol_handler_windows_base.dart';
import 'package:win32_registry/win32_registry.dart';

class ProtocolHandlerWindowsImpl extends ProtocolHandlerWindowsBase {
/// The [ProtocolHandlerWindows] constructor.
ProtocolHandlerWindowsImpl() : super();

/// Registers this class as the default instance of [ProtocolHandlerWindowsImpl].
static void registerWith() {
ProtocolHandlerPlatform.instance = ProtocolHandlerWindowsImpl();
}

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

String protocolRegKey = 'Software\\Classes\\$scheme';
RegistryValue protocolRegValue = const RegistryValue.string(
'URL Protocol',
'',
);
String protocolCmdRegKey = 'shell\\open\\command';
RegistryValue protocolCmdRegValue = RegistryValue.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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:protocol_handler_windows/src/protocol_handler_windows_base.dart';

class ProtocolHandlerWindowsImpl extends ProtocolHandlerWindowsBase {
static void registerWith() {
// Stub implementation does nothing.
}

@override
Future<void> register(String scheme, {String? friendlyAppName}) async {
// Stub implementation does nothing.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:protocol_handler_windows/src/protocol_handler_windows_base.dart';

class ProtocolHandlerWindowsImpl extends ProtocolHandlerWindowsBase {
ProtocolHandlerWindowsImpl() : super();

static void registerWith() {
// Web implementation does nothing.
}

Future<void> register(String scheme, {String? friendlyAppName}) async {
// Web implementation does nothing.
}
}
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