缺少选择器,如’.identifier’或'[0]’。尝试添加一个选择器。

huangapple go评论70阅读模式
英文:

Missing selector such as '.identifier' or '[0]'. Try adding a selector

问题

TextField(
  controller: _searchController,
  onChanged: (value) => {
    List<Job> filteredList = _jobsList.where((job) => job.data.companyCode.contains(value)).toList()
  },
)
英文:
TextField(
              controller: _searchController,
              onChanged: (value) =&gt; {
               List&lt;Job&gt; filtedList  = _jobsList.where((job)=&gt;job.data.companyCode.contains(value)).toList()   
              },
)

缺少选择器,如’.identifier’或'[0]’。尝试添加一个选择器。
缺少选择器,如’.identifier’或'[0]’。尝试添加一个选择器。

what i wanna do here is just filter a list, but vscode complains about the above error.
if I change to var ,also some errors occurred, what I did wrong? thanks

答案1

得分: 1

尝试删除 =&gt;

 onChanged: (value) {
               List<Job> filtedList  = _jobsList.where((job)=>job.data.companyCode.contains(value)).toList();
}

=&gt; 运算符不需要 {} 包裹,它返回一行代码。

可以参考这个答案

英文:

Can you try removing =&gt;

 onChanged: (value) {
               List&lt;Job&gt; filtedList  = _jobsList.where((job)=&gt;job.data.companyCode.contains(value)).toList();
}

=&gt; operator doesn't required {} enclosures, it return one liner code.

Can refer this answer

huangapple
  • 本文由 发表于 2023年6月26日 09:07:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552990.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定