Flutter 无法分析颤振/省道中的文件
需要一些帮助来获取文件内容 我使用颤振文件选择器插件来获取文件。插件返回路径 “/Users//Library/Developer/CoreSimulator/Devices/A509517C-AC3F-4F87-856A-145F61075E8B/data/Containers/data/Application/FC2B634B-F7BD-48EB-9B80-920476E20DE8/tmp/com.xyx Inbox/myfile.doc” 当我试图在Dart中读取内容时,我发现了错误 颤振:FileSystemException:无法使用编码“utf-8”解码数据 这是我的密码Flutter 无法分析颤振/省道中的文件,flutter,dart,Flutter,Dart,需要一些帮助来获取文件内容 我使用颤振文件选择器插件来获取文件。插件返回路径 “/Users//Library/Developer/CoreSimulator/Devices/A509517C-AC3F-4F87-856A-145F61075E8B/data/Containers/data/Application/FC2B634B-F7BD-48EB-9B80-920476E20DE8/tmp/com.xyx Inbox/myfile.doc” 当我试图在Dart中读取内容时,我发现了错误 颤振
Future<int> readFileStream(String path) async {
print(path);
File file = await new File(path);
file.length().then((len) {
print(len);
});
try {
// Read the file
String contents = await file.readAsString();
return int.parse(contents);
} catch (e) {
print(e);
// If encountering an error, return 0
return 0;
}
}
我如何阅读内容
感谢您的帮助我猜这是一个二进制的word文档,因此您应该将其读取为字节而不是字符串。我猜这是一个二进制的word文档,因此您应该将其读取为字节而不是字符串