Flutter 无法从资源中打开文件
这是我的密码Flutter 无法从资源中打开文件,flutter,dart,Flutter,Dart,这是我的密码 文件('assets/i18n/en/strings.xml')。readAsString()。然后((字符串内容){ 印刷(内容); }); strings.xml位于此路径 在publispec.yaml flutter: assets: - assets/i18n/en/strings.xml 然而,我有这个错误 [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: FileSystemException
文件('assets/i18n/en/strings.xml')。readAsString()。然后((字符串内容){
印刷(内容);
});
strings.xml位于此路径
在publispec.yaml
flutter:
assets:
- assets/i18n/en/strings.xml
然而,我有这个错误
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: FileSystemException: Cannot open file, path = 'assets/i18n/en/strings.xml' (OS Error: No such file or directory, errno = 2)
是否有任何地方我需要检查才能使用文件
类?如果您想在颤振中使用资产
:
import'包:flatter/services.dart'显示rootBundle;
loadString('assets/i18n/en/strings.xml')。然后((字符串内容){
印刷(内容);
});
如果您想了解更多信息,可以按照。您的酒吧信息?您是否记得“导入”dart:io“;@VidorVistrom+Yushin这些建议都是徒劳的。谢谢您的建议。我的问题由答案解决了。谢谢!!!问题是我在main.dart中使用了assets系统,但我分离了该文件。所以我忘了在源代码中导入services.dart。