FileSystemException:无法打开文件

时间:2020-08-27 08:53:51

标签: flutter dart file-io

我具有以下功能(直接来自dart文档):

readData() {
  final file = new File('gene_list_parsed.txt');
  Stream<List<int>> inputStream = file.openRead();

  inputStream
      .transform(utf8.decoder) // Decode bytes to UTF-8.
      .transform(new LineSplitter()) // Convert stream to individual lines.
      .listen((String line) {
    // Process results.
    print('$line: ${line.length} bytes');
  }, onDone: () {
    print('File is now closed.');
  }, onError: (e) {
    print(e.toString());
  });
}

由于某种原因,我得到了I/flutter (23598): FileSystemException: Cannot open file, path = 'gene_list_parsed.txt' (OS Error: No such file or directory, errno = 2)
该文件与main.dart在同一目录中-这是我正在执行的文件。

我不确定它是否相关,但这是flutter应用程序的一部分。

0 个答案:

没有答案