W3cubDocs

/Dart 2

convert method

List<String> convert (String data)

Implementation

List<String> convert(String data) {
  var lines = <String>[];
  var end = data.length;
  var sliceStart = 0;
  var char = 0;
  for (var i = 0; i < end; i++) {
    var 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;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-convert/LineSplitter/convert.html