handleSource method

dynamic handleSource(
  1. String string,
  2. int errorLine
)

Implementation

handleSource(String string, int errorLine) {
  var lines = string.split('\n');
  var lines2 = [];

  int from = Math.max(errorLine - 6, 0);
  int to = Math.min(errorLine + 6, lines.length);

  for (var i = 0; i < lines.length; i++) {
    lines[i] = "${(i + 1)}: ${lines[i]}";
  }

  for (var i = from; i < to; i++) {
    lines2.add("${(i + 1)}: ${lines[i]}");
  }

  return lines2.join('\n');
}