简体   繁体   English

TabBarView动态更新列表

[英]TabBarView dynamic update List

I have multiple TabBarView which generates dynamic Products List 我有多个TabBarView生成动态产品List

TabBarView(
     controller: categoryTabController,
     children: List<Widget>.generate(categories.length,
               (index) => Products(categories[index])),
         ),

I have another TextField widget and when I type something I would like to update List<Widget> inside TabBarView , with new Products(categories[index])) List content. 我有另一个TextField小部件,当我输入内容时,我想更新TabBarView List<Widget> ,使用新的Products(categories[index]))列出内容。

TextField( onChanged: (text) {
           // need to update List<Widget> in above TabBarView
          },
       ),

how can I acheive it? 我怎么能实现呢?

I was able to do so using setState 我能够使用setState这样做

TextField(
      onChanged: (text) {
        setState(() {
          userSearch = text;
        });
      },

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

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