'I was trying to switch between expense and income using switch in flutter
I was working on project that calculate income and expense i used switch in the data entry to identify whether it is income or expense but i must have missed something because i used the bool value to display the item it work at the first entry but in the next entry it changes the first also please help me?
`
// this is the code i was trying to loop
ListView.builder(
itemCount: todayFilteredList.length,
itemBuilder: (context, index) {
return data.isIncome == true
? TransactionTileIncome(
index: index,
expense: todayFilteredList[index],
)
: TransactionTileExpense(
index: index,
expense: todayFilteredList[index],
);
},
),
`
Solution 1:[1]
data.isIncome == true
change this into
data.isIncome
You need not compare variable to true, the expression is already true of false.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
