wwwdata / implicitly_animated_reorderable_list

Fork of the discontinued plugin to continue maintaining it
MIT License
32 stars 22 forks source link

Draggable via long press instead of Handle #16

Closed A5H1Q closed 1 year ago

A5H1Q commented 1 year ago

Thank you for the wonderful library. How can I make the ListTile draggable when long pressed. Below is my current code, which uses a handler in trailing of the LisTile, is there any way to make the ListTile draggable when users long presses the ListTile itself ?

              trailing: const Handle(
                delay: Duration(milliseconds: 0),
                capturePointer: true,
                child: Icon(
                  Icons.drag_handle,
                  color: Colors.grey,
                ),
              ),
qwertyway commented 1 year ago

It is mentioned in the documentation

// The child of a Handle can initialize a drag/reorder. // This could for example be an Icon or the whole item itself

So something like this worked for me:

 itemBuilder: (context, animation, item, index) {
    return Reorderable(
      key: ValueKey(item),
      child: SizeFadeTransition(
        sizeFraction: 0.7,
        curve: Curves.easeInOut,
        animation: animation,
        child: Handle(
          delay: dragDuration,
          child: _buildChild(item),
        ),
      ),
    );
  }
A5H1Q commented 1 year ago

Handle( delay: dragDuration, child:

this works. thank you.