I have an issue guys. There is a listView
I am using to show a list fetched from api. So, I implemented filtering
function to it, which works well. The issue I have is I discovered that when I tap on a filtered list item, the index value tend to change inside my listTile onTap
method. How do I retain the original list index structure even after filtering and ensure it works well on tapping.
FutureBuilder(
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Expanded(
child: ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: filteredList.length,
itemBuilder: (context, index) {
//index value and structure changes while filtering
return Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
decoration: BoxDecoration(
color: HexColor("#F5F5F5"),
borderRadius:
BorderRadius.circular(
16.0)),
child: ListTile(
onTap: () => {
showFundModal(index)},
//when I tap on a listView item while filtered, the index not correct
contentPadding: const EdgeInsets.all(8.0),
);