Frame.caller constructor

Frame.caller([
  1. int level = 1
])

Returns a single frame of the current stack.

By default, this will return the frame above the current method. If level is 0, it will return the current method's frame; if level is higher than 1, it will return higher frames.

Implementation

factory Frame.caller([int level = 1]) {
  if (level < 0) {
    throw ArgumentError('Argument [level] must be greater than or equal '
        'to 0.');
  }

  return Trace.current(level + 1).frames.first;
}