debugPrintStack function
Dump the current stack to the console using debugPrint and FlutterError.defaultStackFilter.
The current stack is obtained using StackTrace.current.
The maxFrames
argument can be given to limit the stack to the given number
of lines. By default, all non-filtered stack lines are shown.
The label
argument, if present, will be printed before the stack.
Implementation
void debugPrintStack({ String label, int maxFrames }) {
if (label != null)
debugPrint(label);
Iterable<String> lines = StackTrace.current.toString().trimRight().split('\n');
if (maxFrames != null)
lines = lines.take(maxFrames);
debugPrint(FlutterError.defaultStackFilter(lines).join('\n'));
}