Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在同一个包中声明它们时,拦截器工作,但是当我在不同的包中声明它们时,它们没有被注册并且永远不会被调用。
如何使用在不同包中声明的拦截器?
如果您只是使用带有零件的单个库来拥有多个组,则可以这样做。您创建一个/lib包含所有组的库(在 中)。例如:library rest_api
/lib
library rest_api
然后,在你启动红石的主文件中:
app.redstoneSetUp([#rest_api]);
确保首先导入库。分析器很可能会给你一个未使用的导入警告,但你可以通过添加来忽略它
// ignore: unused_import
在产生警告的行之前或行尾。