问题描述
情况:
我有两个列表,tabsText
和mainListAllPlantDetailsList1
。
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;
}
}
}
}
在这里,我已经检查了tabsText
和mainListAllPlantDetailsList1
。如果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 (将#修改为@)