knopp / flutter_reorderable_list

ReorderableList for Flutter
BSD 3-Clause "New" or "Revised" License
336 stars 98 forks source link

Add behavior(HitTestBehavior) to ReorderableListener #17

Open mono0926 opened 4 years ago

mono0926 commented 4 years ago

Before this change, transparent area of ReorderableListener doesn't react to onPointerDown.

This can be reproduced by commenting out this line: https://github.com/knopp/flutter_reorderable_list/blob/327f51efd68a8f15f9d87af3053c8e7c4d168669/example/lib/main.dart#L194

And the problem is fixed by specifying behavior: HitTestBehavior.opaque, so that parameter is needed.

    Widget dragHandle = draggingMode == DraggingMode.iOS
        ? ReorderableListener(
            child: Container(
              padding: EdgeInsets.only(right: 18.0, left: 18.0),
//              color: Color(0x08000000),
              child: Center(
                child: Icon(Icons.reorder, color: Color(0xFF888888)),
              ),
            ),
            // Add this
            behavior: HitTestBehavior.opaque,
          )
        : Container();

Original code:

https://github.com/knopp/flutter_reorderable_list/blob/327f51efd68a8f15f9d87af3053c8e7c4d168669/example/lib/main.dart#L190-L200