readFileAsLineByline method
Reads a file line by line. Parameters:
filePath
: The path of the file to be read. Returns: Future<List<String?>>, a list of lines in the file. Throws FileReadException if there is an error reading the file.
Implementation
Future<List<String?>> readFileAsLineByline({
required String filePath,
}) async {
try {
var fileAsString = await File(filePath).readAsString();
var fileContent = fileAsString.split('\n');
_checkFileExists(
fileContent: fileContent,
filePath: filePath,
);
return fileContent;
} catch (e) {
throw FileReadException(
filePath: filePath,
platform: platform,
details: e.toString(),
);
}
}