Deleting elements

One of the touch gestures that has won a wide adoption over time in mobile apps is the "swipe-to-delete" gesture, in which you simply drag a finger across an item, and swipe it left—or in some cases, also right.

This was introduced by Apple in the Mail app, and today it's widely spread in both iOS and Android systems.

What we want to achieve here is to delete an item in the ListView by swiping left or right. The first step is creating a method in our DbHelper class that will actually delete a record from the database, as follows:

  1. We'll call this method deleteList(). As usual, it will be asynchronous and will return a Future of type int, and take the ShoppingList object that needs to be deleted.
  2. Inside the method, we need ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.