I have been struggling since I am new to flutter. I am trying to generate a list with total of 10 items, I would like to have 5 of the items the border radius be blue while the other 5 will becolor yellow, only the color blue renders not the other one. Please help. Here's my code. code
CodePudding user response:
You don't change anywhere the variable unread (moreover it is marked as final). I don't understand all of your code, but I think you can replace this line color: unread ? Colors.blue : Colors.yellowAccent with color: d < 5 ? Colors.blue : Colors.yellowAccent. The first 5 items will have blue border, the next five will have yellow color.
PS: This statement doesn't make sense unread ? 5 : 5. If unread is true then the 'first' 5 will be returned, otherwise the 'second' 5 will be returned. In both cases you will have always 5. If you want to generate 10 items you can use List.generate(10, (d){....})
CodePudding user response:
Though it took me time to understand what you want, implementing it would require you to change the value of unread either on a trigger of somekind of a button or something by using setState(() {}) or any state manager you'll be using.
P.S Please paste code instead of images.
