stackTraceIdentifier static method

String stackTraceIdentifier([
  1. int stackOffset = 0
])

Implementation

static String stackTraceIdentifier([int stackOffset = 0]) {
  var stackTracer = StackTrace.current;
  var stackTraceStr = stackTracer.toString();

  var lines = stackTraceStr.split(RegExp(r'[\r\n]+', multiLine: false));

  var start = Math.min(1 + stackOffset, lines.length - 1);
  var end = Math.min(3, lines.length);

  lines = lines.sublist(start, Math.max(start, end));

  var s = lines.join('\n');
  return s;
}