flutter - 使用 GetIt 和 Injectable 注册路径提供程序时出现问题
问题描述
我正在尝试将 path_provider 注册为依赖项,但它现在可以正常工作。
@preResolve
Future<Directory> get appDirectory => getExternalStorageDirectory();
但错误说A value of type 'Future<Directory?>' can't be returned from the function 'appDirectory' because it has a return type of 'Future<Directory>'
所以我这样改了
@preResolve
Future<Directory?> get appDirectory => getExternalStorageDirectory();
在此之后,我得到一个运行时错误
Error: Type argument 'Directory?' doesn't conform to the bound 'Object' of the type variable 'T' on 'GetItHelper.lazySingletonAsync'.
我该如何解决这个问题?
解决方案
推荐阅读
- vb.net - 仅在某些图层上带有复选框的 VB.net TreeView
- laravel - 在 Laravel/Eloquent 中使用 with 从父表和子模型中检索自定义字段和其他一些自定义字段
- sql-server-2008-r2 - 确定链接服务器上的表还是视图
- java - 从 spring mvc 上的数据库下载文件是否有文件大小限制?
- c# - 使用 string.replace c# mvc 时获取可点击链接
- asp.net - signalr-no-jquery 连接已启动,但未使用 websockets 调用客户端事件
- python - 使用来自多个 CheckboxSelectMultiple 的值列表验证 django 表单
- vue.js - 带有 v-for 的动态 v-model
- c++ - 将整数转换为 24 小时格式 C++
- java - 你能强制 JAXB2 Maven 插件从“空”元素创建一个 Java 类吗?