sortable_list 1.0.0 copy "sortable_list: ^1.0.0" to clipboard
sortable_list: ^1.0.0 copied to clipboard

Flutter list widget that allows to drag and drop items and define custom drag handle widget. Inspired by drag_list package (discontinued).

SortableList #

pub package

Flutter list widget that allows to drag and drop items and define custom drag handle widget.

Getting Started #

Add SortableList component to your widget tree:

child: SortableList<String>(
  items: ['Tuna', 'Meat', 'Cheese', 'Potato', 'Eggs', 'Bread'],
  itemExtent: 72.0,
  builder: (context, item, handle) {
    return Container(
      height: 72.0,
      child: Row(children: [
        Spacer(),
        Text(item),
        Spacer(),
        handle,
      ]),
    );
  },
),

Optionally, provide custom handle builder:

child: SortableList<String>(
  // ...
  handleBuilder: (context) {
    return Padding(
      padding: EdgeInsets.all(16.0),
      child: Container(
        color: Colors.green,
        child: Text('Handle'),
      ),
    );
  },
),

Add other optional parameter if needed:

child: SortableList<String>(
  // ...
  animDuration: Duration(milliseconds: 500),
  dragDelay: Duration(seconds: 1),
  handleAlignment: -0.3,
  scrollDirection: Axis.horizontal,
  onItemReorder: (from, to) {
    // handle item reorder on your own
  },
),

Use handleless constructor if you want list item to be dragged no matter where it's tapped on:

SortableList<String>.handleless(
  // ...
  builder: (context, item) {
    return Container(
      height: 72.0,
      child: Center(child: Text(item)),
    );
  },
),

Many thanks to Tomek Wyrowiński - author of original 'Drag_list' package.

3
likes
110
pub points
58%
popularity

Publisher

unverified uploader

Flutter list widget that allows to drag and drop items and define custom drag handle widget. Inspired by drag_list package (discontinued).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

async, flutter

More

Packages that depend on sortable_list