SwiftUI: How to delete or move List rows?
Delete a row:
In SwiftUI user can easily delete the row by adding .onDelete(perform:) handler to the row. The action to perform by SwiftUI when rows in the List are deleted. SwiftUI passes a set of indices for deleting the rows..
Move a row:
To move a row from one index to another use .onMove(perform:) . This is a closure that is invoked by SwiftUI when rows in the List are moved. This closure takes two arguments that represent the old offset of row and new offset of row where it need to be moved.
Note: To disable moving of rows in editing mode pass nil to closure. .onMove(perform: nil)
So, complete implementation for deleting or moving a row will look like below: