I have a screen with a list of items , when I click on an item it opens a page with another controller with item details , item details contains a delete button , when I delete the item and go back to the first screen , the deleted item is still there and I must restart the app to disappear , How to make that approach ?
CodePudding user response:
You need to remove the deleted item from your ListController
's list as well.
Your DetailsController
's delete
method should look like this:
delete(int id) async{
await itemService.delete(id);
final ListController listController = Get.find();
var index = listController.indexWhere((element) => element.id == id);
listController.removeAt(index);
listController.update();
}