【发布时间】:2019-11-05 13:22:41
【问题描述】:
为什么会导致崩溃?
final directory = await getApplicationDocumentsDirectory();
final testFile = File("${directory.path}/test.txt");
await testFile.writeAsString("Hello there!", flush: true);
final ByteData bytes = await rootBundle.load(testFile.path);
rootBundle.load() 调用原因:
未处理的异常:无法加载资产:/data/user/0/com.flutter.tests/app_flutter/test.txt
但是,如果我进行热重载,那么它可以正常工作,直到我重新启动应用程序。
我在 pubspec.yaml 中有一个依赖项 path_provider: any,这是 getApplicationDocumentsDirectory() 所需要的。
【问题讨论】:
标签: flutter