tomwyr/drag-list


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

License: MIT

Language: Dart


DragList

pub package

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

DragList demo

Getting Started

Add DragList component to your widget tree:

child: DragList<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: DragList<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: DragList<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:

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

Project Statistics

Sourcerank 6
Repository Size 122 KB
Stars 21
Forks 8
Watchers 2
Open issues 1
Dependencies 3
Contributors 4
Tags 0
Created
Last updated
Last pushed

Top Contributors See all

tomwyr alan kaiser ahmad Givekesh Ryan Bell

Packages Referencing this Repo

drag_list
Flutter list widget that allows to drag and drop items and define custom drag handle widget.
Latest release 1.0.8 - Updated - 21 stars

Something wrong with this page? Make a suggestion

Last synced: 2020-04-27 18:36:20 UTC

Login to resync this repository