flutter_swipe_actions 0.1.0
flutter_swipe_actions: ^0.1.0 copied to clipboard
Smooth iOS Mail-inspired swipe actions for Flutter lists, with a reusable controller and customizable action buttons.
flutter_swipe_actions #
Smooth swipe actions for Flutter lists, inspired by the iOS Mail interaction.
The package includes:
SwipeActions: wraps a list item and reveals leading or trailing actions.SwipeController: keeps only one row open at a time and exposes open/close helpers.SwipeActionButton: a reusable circular action button with a label.- RTL-aware direction handling.
- Animated item decoration and action transitions.
Usage #
final swipeController = SwipeController();
SwipeActions(
controller: swipeController,
leadingActions: [
SwipeActionButton(
icon: const Icon(Icons.mark_email_unread_outlined),
label: 'Unread',
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
onPressed: () {},
),
],
trailingActions: [
SwipeActionButton(
icon: const Icon(Icons.flag_outlined),
label: 'Flag',
backgroundColor: Colors.orange,
foregroundColor: Colors.white,
onPressed: () {},
),
SwipeActionButton(
icon: const Icon(Icons.archive_outlined),
label: 'Archive',
backgroundColor: Colors.purple,
foregroundColor: Colors.white,
onPressed: () {},
),
],
child: const ListTile(
title: Text('YOVIRT LLC via TestFlight'),
subtitle: Text('SI7ES 1.0.44 is ready to test on iOS.'),
),
)
Controller #
Use a shared SwipeController for every row in the same list:
final swipeController = SwipeController();
// Programmatically close the currently open item.
swipeController.closeAll();
This prevents multiple rows from staying open at the same time.
Visual tuning #
The default spacing is compact, closer to iOS Mail. You can still customize it:
SwipeActions(
actionWidth: 72,
actionSpacing: 4,
itemBorderRadius: BorderRadius.circular(20),
openedDecoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
trailingActions: const [],
child: child,
)
Compatibility #
actions is kept as an alias for trailing actions:
SwipeActions(
actions: [SwipeActionButton(...)],
child: child,
)
For new code, prefer leadingActions and trailingActions.