parse static method

Future<List<Record>> parse(
  1. String filePath
)

Implementation

static Future<List<Record>> parse(String filePath) async {
  List<Record> records;
  records = [];
  if (filePath.isEmpty) {
    return throw FileMustBeProvided();
  }
  final stringFile = await File(filePath).readAsString();
  final lines = stringFile.split('\n');
  var record = Record.empty();
  for (var line in lines) {
    if (line.isEmpty) {
      break;
    }
    if (ParseLine.isEndOfRecord(line)) {
      records.add(record);
      record = Record.empty();
    } else {
      final lineParsed = ParseLine.parse(line);
      Transformer.transform(record, lineParsed);
    }
  }
  return records;
}