严重的injectable_generator:injectable_builder ...类型“UnspecifiedInvalidResult”不是类型转换中“LibraryElementResult”类型的子类型

w46*_*461 5 flutter build-runner

当重构我的代码和执行 build_runner 时,我突然收到了类似的错误

[SEVERE] injectable_generator:injectable_builder on lib/application/authorization/xxx data_sync/sync_data.dart (cached):

type 'UnspecifiedInvalidResult' is not a subtype of type 'LibraryElementResult' in type cast
Run Code Online (Sandbox Code Playgroud)

可以看出,它们是由注射包产生的。

Ram*_*.M. 10

就我而言,我收到了类似的错误:

[SEVERE] injectable_generator:injectable_config_builder on lib/main/di/dependency_injection.dart (cached):

Stack Overflow
[SEVERE] Failed after 118ms
pub finished with exit code 1
Run Code Online (Sandbox Code Playgroud)

我发现我的问题发生是因为我有循环注入...这意味着我正在向拦截器注入一个在其内部注入了 Dio 客户端的类...这是一个明显的循环,所以我必须删除注入的类。

我不确定这是否相关,但我发布了一个答案,因为网上没有关于此错误的更多信息......


w46*_*461 1

这是由目录名称中的空格引起的。我已经xxx 预先添加了尚未重构的目录名称。

所以改变xxx data_syncxxx_data_sync解决这个问题。有趣的是,我正在重构干净的架构并使用脏文件夹名称......