diff --git a/packages/flutter/lib/src/foundation/stack_frame.dart b/packages/flutter/lib/src/foundation/stack_frame.dart index ab1eefd4a9..4b4ea28ed6 100644 --- a/packages/flutter/lib/src/foundation/stack_frame.dart +++ b/packages/flutter/lib/src/foundation/stack_frame.dart @@ -59,6 +59,18 @@ class StackFrame { source: '', ); + /// A stack frame representing a Dart elided stack overflow frame. + static const StackFrame stackOverFlowElision = StackFrame( + number: -1, + column: -1, + line: -1, + method: '...', + packageScheme: '', + package: '', + packagePath: '', + source: '...', + ); + /// Parses a list of [StackFrame]s from a [StackTrace] object. /// /// This is normally useful with [StackTrace.current]. @@ -113,6 +125,8 @@ class StackFrame { assert(line != null); if (line == '') { return asynchronousSuspension; + } else if (line == '...') { + return stackOverFlowElision; } // Web frames. diff --git a/packages/flutter/test/foundation/stack_frame_test.dart b/packages/flutter/test/foundation/stack_frame_test.dart index 0c86f5fe77..7fc7724828 100644 --- a/packages/flutter/test/foundation/stack_frame_test.dart +++ b/packages/flutter/test/foundation/stack_frame_test.dart @@ -47,6 +47,28 @@ void main() { webStackTraceFrames, ); }); + + test('Parses ...', () { + expect( + StackFrame.fromStackTraceLine('...'), + StackFrame.stackOverFlowElision, + ); + }); + + test('Live handling of Stack Overflows', () { + void overflow(int seed) { + overflow(seed + 1); + } + bool overflowed = false; + try { + overflow(1); + } on StackOverflowError catch (e, stack) { + overflowed = true; + final List frames = StackFrame.fromStackTrace(stack); + expect(frames.contains(StackFrame.stackOverFlowElision), true); + } + expect(overflowed, true); + }, skip: isBrowser); } const String stackString = '''#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)