Unverified Commit 920961ab authored by Ferhat's avatar Ferhat Committed by GitHub

[web][upstream] Fix debugPrintStack for web platform (#37638)

* [web][upstream] Fix debugPrintStack for web platform

Fixes: https://github.com/flutter/flutter/issues/37488
parent 626ca086
...@@ -750,6 +750,12 @@ void debugPrintStack({ String label, int maxFrames }) { ...@@ -750,6 +750,12 @@ void debugPrintStack({ String label, int maxFrames }) {
if (label != null) if (label != null)
debugPrint(label); debugPrint(label);
Iterable<String> lines = StackTrace.current.toString().trimRight().split('\n'); Iterable<String> 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) if (maxFrames != null)
lines = lines.take(maxFrames); lines = lines.take(maxFrames);
debugPrint(FlutterError.defaultStackFilter(lines).join('\n')); debugPrint(FlutterError.defaultStackFilter(lines).join('\n'));
......
...@@ -14,7 +14,7 @@ void main() { ...@@ -14,7 +14,7 @@ void main() {
}); });
expect(log[0], contains('Example label')); expect(log[0], contains('Example label'));
expect(log[1], contains('debugPrintStack')); expect(log[1], contains('debugPrintStack'));
}, skip: isBrowser); });
test('debugPrintStack', () { test('debugPrintStack', () {
final List<String> log = captureOutput(() { final List<String> log = captureOutput(() {
...@@ -39,7 +39,7 @@ void main() { ...@@ -39,7 +39,7 @@ void main() {
expect(joined, contains('captureOutput')); expect(joined, contains('captureOutput'));
expect(joined, contains('\nExample information\n')); expect(joined, contains('\nExample information\n'));
}, skip: isBrowser); });
test('FlutterErrorDetails.toString', () { test('FlutterErrorDetails.toString', () {
expect( expect(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment