From 920961abc8163fd68585c514cffd0fc254572a24 Mon Sep 17 00:00:00 2001 From: Ferhat Date: Tue, 6 Aug 2019 13:22:40 -0700 Subject: [PATCH] [web][upstream] Fix debugPrintStack for web platform (#37638) * [web][upstream] Fix debugPrintStack for web platform Fixes: https://github.com/flutter/flutter/issues/37488 --- packages/flutter/lib/src/foundation/assertions.dart | 6 ++++++ packages/flutter/test/foundation/assertions_test.dart | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart index ab61f529fe..adcb3a188f 100644 --- a/packages/flutter/lib/src/foundation/assertions.dart +++ b/packages/flutter/lib/src/foundation/assertions.dart @@ -750,6 +750,12 @@ void debugPrintStack({ String label, int maxFrames }) { if (label != null) debugPrint(label); Iterable lines = StackTrace.current.toString().trimRight().split('\n'); + if (kIsWeb) { + // Remove extra call to StackTrace.current for web platform. + // TODO(ferhat): remove when https://github.com/flutter/flutter/issues/37635 + // is addressed. + lines = lines.skip(1); + } if (maxFrames != null) lines = lines.take(maxFrames); debugPrint(FlutterError.defaultStackFilter(lines).join('\n')); diff --git a/packages/flutter/test/foundation/assertions_test.dart b/packages/flutter/test/foundation/assertions_test.dart index 821d11f666..4b933ca9c8 100644 --- a/packages/flutter/test/foundation/assertions_test.dart +++ b/packages/flutter/test/foundation/assertions_test.dart @@ -14,7 +14,7 @@ void main() { }); expect(log[0], contains('Example label')); expect(log[1], contains('debugPrintStack')); - }, skip: isBrowser); + }); test('debugPrintStack', () { final List log = captureOutput(() { @@ -39,7 +39,7 @@ void main() { expect(joined, contains('captureOutput')); expect(joined, contains('\nExample information\n')); - }, skip: isBrowser); + }); test('FlutterErrorDetails.toString', () { expect(