I have two lists,tabsText
and 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",
price: 147,
description: "This is the Hughusi Yoon indoor"
),
PlantDetails(
indexNumber: 3,
category: "outdoor",
plantName: "lily",
price: 120,
description: "This is the lily outdoor"
),
];
I have made the TabBar using for loop in the tabsText
list. Now I am again making the TabBarView
using for loop and I tried like this
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;
}
}
}
}
Here, I have checked the tabsText
and mainListAllPlantDetailsList1
. If the String of particular index of tabsText
is equal to particular index of mainListAllPlantDetailsList1
then, generate a widget,
Text("We found category"+tabsText[i])
otherwise just continue. And I have made a list of type widget and added all the text widget, but while calling the function tabViewerMaker
Why does it give error?
══╡ 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.
How can I achieve the desired function using for loop or feel free to give any suggestion?
User contributions licensed under CC BY-SA 3.0