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)),
);
})
),
),
),
在上面的代码中,我想在onTap中执行一个功能,当点击该功能时,将该特定列表的图标Only更改为Icon(Icons.done)。
我试着使用setState,但找不到它。
2条答案
按热度按时间a8jjtwal1#
现在传递值,
oknwwptz2#
创建一个状态级变量,
单击按钮时更改变量值,并相应地更改值。