List<String> convert(String data)

Converts input and returns the result of the conversion.

Source

List<String> convert(String data) {
  List<String> lines = <String>[];
  int end = data.length;
  int sliceStart = 0;
  int char = 0;
  for (int i = 0; i < end; i++) {
    int previousChar = char;
    char = data.codeUnitAt(i);
    if (char != _CR) {
      if (char != _LF) continue;
      if (previousChar == _CR) {
        sliceStart = i + 1;
        continue;
      }
    }
    lines.add(data.substring(sliceStart, i));
    sliceStart = i + 1;
  }
  if (sliceStart < end) {
    lines.add(data.substring(sliceStart, end));
  }
  return lines;
}