简体   繁体   中英

Flutter: how to delete item in ListTile

If i use Navigator, class is finished by itself. I just want to delete the list.

code image is here

Add an itemCount to your 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

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),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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