操作系统错误:无此类文件或目录,errno = 2,未处理的异常:FileSystemException

时间:2019-10-18 09:48:14

标签: flutter dart dart-io

E / flutter(13503):[错误: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

1 个答案:

答案 0 :(得分:0)

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

相关问题