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