首页 > 解决方案 > Flutter:读取文件内容

问题描述

我正在基于现有的 iOS 应用程序(在 appStore 上发布)创建一个 Flutter 应用程序,我需要读取旧 iOS 应用程序(notes.data)中现有文件的内容,我做了什么:

String fileName = "notes.data";
String dir = (await getApplicationDocumentsDirectory()).path;
String savePath = '$dir/$fileName';

if (await File(savePath).exists()) {
   print("File exists");
   var readAsBytes = await File(savePath).readAsBytesSync();
   print(utf8.decode(readAsBytes));
}

它打印文件存在,但我无法获取文件的内容。

请提供任何帮助。

标签: flutterflutter-layoutflutter-dependencies

解决方案


推荐阅读