Search packages, repositories and app categories

GitHub repositoryholotrek/selectable_draggable_listbox

selectable_draggable_listbox

holotrek/selectable_draggable_listbox open-source repository details.

selectable_draggable_listbox project cover
Stars
1
Forks
0
Last push (UTC)
Jul 14, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Pub License: MIT

selectable_draggable_listbox

Listbox with multiselect, drag & drop between lists, and reorder built in.

Features

  • Bind your data to a listview of custom widget
    • Simple text item widget -or-
    • Templated list item widget for more cusomizability
  • Multi-select items
    • Shift-click to select items in sequence
    • Ctrl/Cmd-click to select individual items
    • Single-select only option available
  • Reorderable
    • Click & drag the "three lines" icon to reorder item
  • Drag & Drop
    • Drag items from/to different lists
    • Each list may independently be a draggable, drop target, or both

Feature Demo

Getting started

  1. Add the latest version of this package:
  • Run flutter pub add selectable_draggable_listbox -or-
  • Edit pubspec.yaml and then run flutter pub get:
dependencies:
  selectable_draggable_listbox: ^latest_version
  1. Import the package
import 'package:selectable_draggable_listbox/selectable_draggable_listbox.dart';

Usage

// Create your list and transform it to track selected items (list can be complex objects instead):
final myList = ['Apples','Cheese','Bread','Milk'].forListbox().toList();

// Create the listbox widget
return Listbox(
  items: myList,
  itemTemplate: (context, eventManager, index, item, onSelect) {
    // Define the template used for each listitem
    return SimpleListboxItem(
      key: Key('$index'), // Key is required for reordering
      item: item,
      label: item.data,
      eventManager: eventManager,
      onSelect: onSelect,
    );
  },
  onSelect: (itemsSelected) {
    // React to items selected
    // Note: (value of isSelected is not set automatically by Listbox,
    //  due to not knowing how your state is handled)
    setState(() {
      for (var item in myList) {
        item.isSelected = itemsSelected.contains(item);
      }
    });
  },
  onReorder: (oldIndex, newIndex) {
    // React to item reordered
    setState(() {
      // Note: this is an extension provided by the package
      myList.move(oldIndex, newIndex);
    });
  },
);

Advanced Usage

For more info on additional features like Drag & Drop and Customizable Templates, see examples and API:

Support

You can support me by buying me a coffee Buy me a coffee

And also don't forget to star this package on GitHub

Evan Kaiser GitHub avatar
GitHub author

Evan Kaiser ↗

LanguagesDartC++CMakeHTMLSwiftCKotlinObjective-C

Packages published by this repository

Dependencies used

Dependency list 4 items

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗