E/flutter (13503):错误:flutter/lib/ui/ui_dart_state.cc(148)未处理的异常: FileSystemException:无法打开文件,路径= 'lib/certs/ca.pem‘(操作系统错误:没有这样的文件或目录,错误号= 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和证书都在那里,我需要使用它进行加密。它找不到它,只能在flutter中的实际主函数中找到它。如果我从不同的dart代码文件中读取文件,那么它是有效的,但我希望它在我的项目中。enter image description here
发布于 2020-11-05 03:05:46
将您的certs文件夹从lib文件夹移动到位于您的应用程序根目录中的资产文件夹。如果您没有资源文件夹,请在根目录中创建一个。
https://stackoverflow.com/questions/58448251
复制相似问题