[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:
parent
626ca086d0
commit
920961abc8
@ -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() {
|
|||||||
});
|
});
|
||||||
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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user