ReorderableListView - control long press sensitivity

Viewed 35

I am trying to create a list that can be re-ordered with ReorderableListView.

I prefer not to explicitly show the drag handle icon, but simply enable drag and drop with a long press. That's why I am setting buildDefaultDragHandles to false.

I am wrapping the list rows with ReorderableDragStartListener but it appears that then the drag sensitivity is too light - hence, the drag start requires no long press at all. But when using ReorderableDelayedDragStartListener to solve that problem, it requires a REALLY long press to start the drag.

The only way to solve that problem is to have the developer define by milliseconds what is a "long press" that should trigger the drag start. Hence, how long should a user click on the row for it to trigger the long press.

Is it somehow possible?

@override
  Widget build(BuildContext context) {
    final ColorScheme colorScheme = Theme.of(context).colorScheme;
    final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
    final Color evenItemColor = colorScheme.primary.withOpacity(0.15);

    return ReorderableListView(
      buildDefaultDragHandles: false,
      children: <Widget>[
        for (int index = 0; index < _items.length; index++)
          Container(
            key: Key('$index'),
            child: Row(
              children: <Widget>[
                Container(
                  width: MediaQuery.of(context).size.width,
                  height: 64,
                  padding: const EdgeInsets.all(8),
                  child: ReorderableDragStartListener (
                    index: index,
                    child: ListTile(
                      key: Key('$index'),
                      tileColor: evenItemColor,
                      title: Text('Item ${_items[index]}'),
                    ),
                  ),
                )
              ],
            ),
          ),
      ],
0 Answers
Related