在颤抖中动态制作TabBarView

问题描述

情况:

我有两个列表,tabsTextmainListAllPlantDetailsList1
tabsText

  List<String> tabsText = ["Top","Outdoor","Indoor","Seeds","Flowers"];

mainListAllPlantDetailsList1

List<PlantDetails> mainListAllPlantDetailsList1 = [
    PlantDetails(
      indexNumber: 0,category: "flower",plantName: "Lamb's Ear",price: 147,description: "This is the Lamb's Ear flower"
    ),PlantDetails(
      indexNumber: 1,category: "seeds",plantName: "Lotus",price: 120,description: "This is the lotus seeds"
    ),PlantDetails(
      indexNumber: 2,category: "indoor",plantName: "Hughusi Yoon",description: "This is the Hughusi Yoon indoor"
    ),PlantDetails(
      indexNumber: 3,category: "outdoor",plantName: "lily",description: "This is the lily outdoor"
    ),];

详细信息:

我在tabsText列表中使用for循环制作了TabBar。现在,我再次使用TabBarView进行for循环,并尝试这样

tabViewerMaker(){
  List<Widget> tabBarView = List();
  for(var i = 0; i<tabsText.length;i++){
    for( var j =0; j<mainListAllPlantDetailsList1.length;j++){
      if(tabsText[i] == mainListAllPlantDetailsList1[j].ca){
        tabBarView.add(
        Text("We found category"+tabsText[i])
        );
      }
      else{
        continue;
      }
    }
  }
}

在这里,我已经检查了tabsTextmainListAllPlantDetailsList1。如果tabsText的特定索引的字符串等于mainListAllPlantDetailsList1的特定索引,则生成窗口小部件,
Text("We found category"+tabsText[i]) 否则就继续。而且我列出了类型窗口小部件并添加了所有文本窗口小部件,但是在调用函数tabViewerMaker为什么会出错?

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building Container(bg: BoxDecoration(color:
Color(0xffffffff)),constraints: BoxConstraints(w=Infinity,h=317.0)):
The getter 'key' was called on null.

问题:

如何使用for循环或随意提出任何建议来实现所需的功能?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...