繁体   English   中英

使用重新选择的颤振选择器上的推断类型

[英]inferred type on flutter selector using reselect

我正在尝试将参数传递给基于reselect dart库的自定义selector ,但是我收到以下警告: 无法推断函数文字的类型,因为文字具有自己的主体

final selectCount = (int itemId) {

  return createSelector1 (
      myOtherSelector, (List<Item> items) {
        return items.where((item) => item.id == itemId).length;
      },
  );
};

选择器按预期工作,但这个警告困扰我。 我究竟做错了什么?

编辑:我添加了一个typedef typedef MySelectorFn = Function(int itemId) ,警告消失了。 仍然不确定它是最好的方法来做到这一点。 另外,我对我的选择器的记忆有疑问。 任何见解都是受欢迎的

final MySelectorFn selectCount = (int itemId) {

  return createSelector1 (
      myOtherSelector, (List<Item> items) {
        return items.where((item) => item.id == itemId).length;
      },
  );
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM