zeba_academy_drag_sortable_list
A powerful, flexible, and lightweight Flutter package to create draggable and sortable lists with smooth animations and optional offline persistence.
โจ Features
- ๐ Drag & drop reordering
- ๐งฉ Supports single-level and nested lists
- ๐ฏ Smooth animations with snapping
- ๐พ Optional offline persistence
- โก Lightweight and performant
- ๐จ Fully customizable UI via builder
๐ฆ Installation
Add this to your pubspec.yaml:
dependencies:
zeba_academy_drag_sortable_list: ^0.0.1
๐ Usage
1. Import
import 'package:zeba_academy_drag_sortable_list/zeba_academy_drag_sortable_list.dart';
2. Create Controller
final controller = DragSortController(
items: List.generate(
5,
(i) => SortableItemModel(id: '$i', data: 'Item $i'),
),
onChanged: (items) {
// Handle updated order
},
);
3. Use Widget
ZebaSortableList(
controller: controller,
itemBuilder: (context, item) {
return ListTile(
title: Text(item.data.toString()),
leading: const Icon(Icons.drag_handle),
);
},
)
๐ง Nested List Support
Widget buildNested(SortableItemModel item) {
return Column(
children: [
ListTile(title: Text(item.data.toString())),
if (item.children.isNotEmpty)
Padding(
padding: const EdgeInsets.only(left: 16),
child: Column(
children: item.children.map(buildNested).toList(),
),
)
],
);
}
๐พ Persistence Example
controller = DragSortController(
items: items,
onChanged: (items) async {
await SortPersistence.save(items);
},
);
๐งช Testing
Run tests:
flutter test
๐ Project Structure
lib/
โโโ zeba_academy_drag_sortable_list.dart
โโโ src/
โโโ sortable_list.dart
โโโ sortable_item.dart
โโโ drag_controller.dart
โโโ models.dart
๐ License (GPL-3.0)
๐จโ๐ป About Me
โจ Iโm Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects. You can learn more about me and my work at sufyanism.com or connect with me on Linkedin
๐ Your all-in-one no-bloat hub!
๐ Explore cutting-edge resources in coding, tech, and development at zeba.academy and code.zeba.academy. Empower yourself with practical skills through curated directives, real-world projects, and hands-on experience. Level up your tech game today! ๐ปโจ
Zeba Academy is a learning platform dedicated to coding, technology, and development.
โก Visit our main site: https://zeba.academy โก Explore hands-on courses and resources at: https://code.zeba.academy โก Check out our YouTube for more tutorials: https://www.youtube.com/@zeba.academy โก Follow us on Instagram: https://www.instagram.com/zeba.academy/
Thank you for visiting! ๐