[flutter_tools] Forward app.webLaunchUrl event from Flutter to DAP clients (#116275)

* [flutter_tools] Forward app.webLaunchUrl event from Flutter to DAP clients

Fixes https://github.com/Dart-Code/Dart-Code/issues/4292.

* Update packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart

Co-authored-by: Christopher Fujino <fujino@google.com>

* Another static const instead of final

Co-authored-by: Christopher Fujino <fujino@google.com>
This commit is contained in:
Danny Tuppeny
2022-11-30 21:25:07 +00:00
committed by GitHub
parent fcc8ea1177
commit a29796e339
3 changed files with 67 additions and 10 deletions

View File

@@ -51,7 +51,7 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
bool get supportsRestartRequest => true;
/// A list of reverse-requests from `flutter run --machine` that should be forwarded to the client.
final Set<String> _requestsToForwardToClient = <String>{
static const Set<String> _requestsToForwardToClient = <String>{
// The 'app.exposeUrl' request is sent by Flutter to request the client
// exposes a URL to the user and return the public version of that URL.
//
@@ -65,6 +65,14 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
'app.exposeUrl',
};
/// A list of events from `flutter run --machine` that should be forwarded to the client.
static const Set<String> _eventsToForwardToClient = <String>{
// The 'app.webLaunchUrl' event is sent to the client to tell it about a URL
// that should be launched (including a flag for whether it has been
// launched by the tool or needs launching by the editor).
'app.webLaunchUrl',
};
/// Completers for reverse requests from Flutter that may need to be handled by the client.
final Map<Object, Completer<Object?>> _reverseRequestCompleters = <Object, Completer<Object?>>{};
@@ -454,6 +462,17 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
_handleAppStarted();
break;
}
if (_eventsToForwardToClient.contains(event)) {
// Forward the event to the client.
sendEvent(
RawEventBody(<String, Object?>{
'event': event,
'params': params,
}),
eventType: 'flutter.forwardedEvent',
);
}
}
/// Handles incoming reverse requests from `flutter run --machine`.