readFileAsLineByline function
Future<List<String?> >
readFileAsLineByline({
- required String filePath,
- required RenamePlatform platform,
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,
required RenamePlatform platform,
}) async {
try {
var fileAsString = await File(filePath).readAsString();
var fileContent = fileAsString.split('\n');
_checkFileExists(
fileContent: fileContent,
filePath: filePath,
platform: platform,
);
return fileContent;
} catch (e) {
throw FileReadException(
filePath: filePath,
platform: platform,
details: e.toString(),
);
}
}