[flutter_tool] [dap] Forward Flutter progress events to DAP client (#142524)

Builds can be slow and the legacy debug adapter would handle Flutter's `app.progress` events to update the toast notification during builds. This was lost in the new adapters - we should only a single "Launching.." notification for the whole progress.

This change listens to `app.progress` events and forwards those with `finished=false` to the client if the launch progress is still active.

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

https://github.com/flutter/flutter/assets/1078012/8c60cf08-e034-4a72-b31e-9c61dca388bf
This commit is contained in:
Danny Tuppeny
2024-02-15 22:22:48 +00:00
committed by GitHub
parent 7082ae1517
commit 86613d198e
3 changed files with 70 additions and 1 deletions

View File

@@ -420,6 +420,19 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter with VmServiceInfoFile
);
}
/// Handles any app.progress event from Flutter.
void _handleAppProgress(Map<String, Object?> params) {
// If this is a new progress starting (and we're still launching), update
// the progress notification.
//
// We ignore finished status because we have a limited API - the next
// item will replace it (or the launch progress will be completed by
// _handleAppStarted).
if (params case {'message': final String message, 'finished': false}) {
launchProgress?.update(message: message);
}
}
/// Handles the app.started event from Flutter.
Future<void> _handleAppStarted() async {
launchProgress?.end();
@@ -481,6 +494,8 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter with VmServiceInfoFile
_handleDebugPort(params);
case 'app.start':
_handleAppStart(params);
case 'app.progress':
_handleAppProgress(params);
case 'app.started':
_handleAppStarted();
}