searchResult = ['john','doe','smith'];
Expanded(
child: Container(
width: ScreenSize.screenWidth,
child: Center(
child:searchResult.isEmpty? Text("Oops! Looks like you have no friends at the moment.") : ListView.builder(itemCount: searchResult.length,itemBuilder: (context , index){
return ListTile(
title: Text(searchResult[index]['username']),
subtitle: Text(searchResult[index]['email']),
trailing: GestureDetector(
onTap: () {
},
child: Icon(Icons.add_circle_outline)),
);
})
),
),
),
In the above code i want to perform a function in the onTap which when tapped changes the icon of that particular list tile Only to a Icon(Icons.done).
I tried using the setState but couldnt figure it out.
2
Answers
Create a state level variable,
Change the variable value on click on the button and change the value accordingly.
Now pass the value,