简体   繁体   English

Flutter:如何删除 ListTile 中的项目

[英]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.我只想删除列表。

code image is here代码图像在这里

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM