Swipe List Item for more options Flutter
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
Flutter provides the built-in Dismissible widget for swipe-to-delete behavior, but for revealing multiple action buttons (like iOS-style swipe menus), you need either a custom implementation or a package like flutter_slidable. The Dismissible widget handles single-action swipe gestures natively, while flutter_slidable supports multiple actions on both sides of a list item with customizable animations.
Using the Dismissible Widget
Dismissible wraps a list item and detects horizontal swipe gestures. When swiped far enough, it removes the item:
Each Dismissible requires a unique key so Flutter can track which item was swiped.
Controlling Swipe Direction
Available directions:
DismissDirection.endToStart— swipe left (most common for delete)DismissDirection.startToEnd— swipe rightDismissDirection.horizontal— both directions (default)DismissDirection.none— disable swiping
Confirm Before Dismiss
confirmDismiss returns a Future<bool>. Returning false cancels the dismiss and snaps the item back.
Multiple Actions with flutter_slidable
For revealing action buttons without fully dismissing the item, use the flutter_slidable package:
Slidable Motion Types
flutter_slidable supports different animation styles for the action pane:
Closing Slidable Programmatically
Common Pitfalls
- Missing unique keys on Dismissible: Without a unique
Key, Flutter cannot track which item was swiped. Using the index as a key (Key('$index')) causes bugs when items are reordered or removed — use the item's ID instead. - Not removing the item in
onDismissed:Dismissibleonly handles the animation. If you do not remove the item from your data source inonDismissed, the item reappears when the list rebuilds, causing a "duplicate key" error. - Using Dismissible for reveal-style actions:
Dismissibleis designed for swipe-to-delete. It does not support revealing action buttons underneath. Useflutter_slidablefor iOS-style swipe menus with multiple actions. - Forgetting
confirmDismissfor destructive actions: Without a confirmation dialog, swiped items are deleted immediately with no undo. Always addconfirmDismissor provide a snackbar with an undo action. - Nesting Slidable inside scrollable widgets:
Slidablegestures can conflict with horizontalPageVieworTabBarViewwidgets. SetcloseOnScroll: true(the default) and test gesture interactions on real devices.
Summary
Dismissibleis built into Flutter for simple swipe-to-delete behavior- Use
confirmDismissto show a confirmation dialog before removing items flutter_slidableprovides multi-action swipe menus with customizable animations- Each swipeable item needs a unique
Keyfor proper tracking - Choose motion types (
ScrollMotion,StretchMotion,DrawerMotion) to match your design - Always remove the item from your data source in the dismiss callback
Related reading
- Swoole with RabbitMQ
- Symbolicating stripped binary using symbols from older debug version inexact graph matching
- Symfony Messenger with Apache Kafka as queue transport
- Syntax for creating a two-dimensional array in Java
- Swipe to Delete and the More button like in Mail app on iOS 7
- Switching to a TabBar tab view programmatically?
- Tail Recursive Tree Traversal without Loops
- Take multiple lists into dataframe

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.