【问题标题】:OS Error: No such file or directory, errno = 2, Unhandled Exception: FileSystemException操作系统错误:没有这样的文件或目录,errno = 2,未处理的异常:FileSystemException
【发布时间】:2020-02-15 07:08:08
【问题描述】:

E/flutter (13503): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理异常:FileSystemException: 无法打开文件,路径 = 'lib/certs/ca.pem'(操作系统错误:没有这样的文件或目录,errno = 2)

   SecurityContext clientContext = new SecurityContext()
     ..setTrustedCertificates('assets/certs/ca.pem');
   var client = new HttpClient(context: clientContext);

   var request = await client.getUrl(
       Uri.parse('192.168.0.132', 10000));
   var response = await request.close();
  assets:
     - assets/
     - assets/certs/

所有文件都在 lib 文件夹内,在 lib 文件夹内有 certs 文件夹,在 certs 文件夹内,所有 pem 和证书都在那里,我需要使用它进行加密。它找不到它,但在颤振的实际主要功能中。如果我从不同的 dart 代码文件中读取文件,那么它可以工作,但我希望在我的项目中使用它。enter image description here

【问题讨论】:

标签: flutter dart dart-io


【解决方案1】:

将您的 certs 文件夹从 lib 文件夹移动到位于您的应用根目录中的资产文件夹。如果您没有资产文件夹,请在根目录中创建一个。

【讨论】:

    猜你喜欢
    • 2022-12-16
    • 1970-01-01
    • 2020-01-13
    • 2020-08-10
    • 2019-06-29
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 2020-05-13
    相关资源
    最近更新 更多