diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index b7380fde589..8e8b1568a53 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart @@ -672,7 +672,7 @@ class _ResidentWebRunner extends ResidentWebRunner { // thrown if we're not already subscribed. } _stdOutSub = _vmService.onStdoutEvent.listen((vmservice.Event log) { - final String message = utf8.decode(base64.decode(log.bytes)).trim(); + final String message = utf8.decode(base64.decode(log.bytes)); globals.printStatus(message); }); unawaited(_vmService.registerService('reloadSources', 'FlutterTools')); diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 81b58555b46..29b23c8e65d 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -480,6 +480,30 @@ void main() { Usage: () => MockFlutterUsage(), })); + test('Faithfully displays stdout messages with leading/trailing spaces', () => testbed.run(() async { + _setupMocks(); + final StreamController stdoutController = StreamController(); + when(mockVmService.onStdoutEvent).thenAnswer((Invocation invocation) { + return stdoutController.stream; + }); + final Completer connectionInfoCompleter = Completer(); + unawaited(residentWebRunner.run( + connectionInfoCompleter: connectionInfoCompleter, + )); + await connectionInfoCompleter.future; + + stdoutController.add(Event( + timestamp: 0, + kind: 'Stdout', + bytes: base64.encode(utf8.encode(' This is a message with 4 leading and trailing spaces '))), + ); + // Wait one event loop for the stream listener to fire. + await null; + + expect(testLogger.statusText, + contains(' This is a message with 4 leading and trailing spaces ')); + })); + test('Fails on compilation errors in hot restart', () => testbed.run(() async { _setupMocks(); final Completer connectionInfoCompleter = Completer();