Trace.current constructor Null safety
- [int level = 0]
Returns the current stack trace.
By default, the first frame of this trace will be the line where
Trace.current is called. If level
is passed, the trace will start that
many frames up instead.
Implementation
factory Trace.current([int level = 0]) {
if (level < 0) {
throw ArgumentError('Argument [level] must be greater than or equal '
'to 0.');
}
var trace = Trace.from(StackTrace.current);
return LazyTrace(() {
// JS includes a frame for the call to StackTrace.current, but the VM
// doesn't, so we skip an extra frame in a JS context.
return Trace(trace.frames.skip(level + (inJS ? 2 : 1)),
original: trace.original.toString());
});
}