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

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

Fixes: https://github.com/flutter/flutter/issues/37488
This commit is contained in:
Ferhat 2019-08-06 13:22:40 -07:00 committed by GitHub
parent 626ca086d0
commit 920961abc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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'));

View File

@ -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() {
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(