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! ๐Ÿ™Œ