readLines method
按行读取 返回字符串数组 readAsLinesSync() 同步读取 一次性读取整个文件,缺点就是如果文件太大的话,可能造成内存空间的压力。
Implementation
Future<List<String>> readLines(File file) async {
// readAsString()以字符串形式读取 readAsStringSync() 同步读取
List<String> contentStr = [];
final fileExists = await file.exists();
if (fileExists) {
contentStr = await file.readAsLines();
}
return contentStr;
}