[英]Flutter: how to delete item in ListTile
If i use Navigator, class is finished by itself.如果我使用 Navigator,class 会自行完成。 I just want to delete the list.我只想删除列表。
Add an itemCount
to your ListView.Builder
.将itemCount
添加到您的ListView.Builder
。
Then if you want to delete the item at the given index, you can create a function and put it in your onpressed
然后,如果您想删除给定索引处的项目,您可以创建一个 function 并将其放入您的onpressed
deleteItem(int index){
yourList.removeWhere(index);
}
body: Container( child: Center( child: ListView.builder( itemCount: 100, itemBuilder: (context, index) { return ListTile( title: launchButton('linkbutton','https://stackoverflow.com/questions/ask'), trailing: OutlinedButton( onPressed: () { }, child: Icon(Icons.delete_forever),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.