Implementing swiping with the Dismissible widget
Mobile users expect apps to respond to gestures. In particular, swiping an item left or right in a ListView can be used to delete an item from a List.
There’s a very useful widget in Flutter designed to remove an item in response to a swiping gesture from the user. It’s called Dismissible. In this recipe, you will see a simple example that shows how to implement a Dismissible widget in your apps.
Getting ready
To follow along with this recipe, create a new Flutter project, or use the app created in any of the previous recipes.
How to do it...
You will now create a screen with a ListView, and include a Dismissible widget in it:
- Create a new file in the
libfolder calleddismissible.dart. - At the top of the file, import
material.dart:import 'package:flutter/material.dart'; - Create a stateful widget, calling it
DismissibleScreen:class DismissibleScreen...