huhuang03/reorderable_grid_view

How to disable drag on some items of the grid ?

kristijorgji opened this issue · 3 comments

Hi,

we have a grid of 12 items, some of them have photos other are empty.

We want to allow only the items that have photos to be draggable and dropped only on other items that have photos as well!

Items that are just placeholders shouldn't move or be draggable. (example while uploading photos in dating or social apps like Tinder)

How to achieve this? (we know the indexes of the items that are empty and want to disable from the drag&drop mechanism)

The current API design is not very good.

You can see https://github.com/huhuang03/reorderable_grid_view/blob/master/example/lib/demo/demo_custom.dart.

The key is:

  1. Use a ReorderableWrapperWidget as a wrapper for your real GridView
  2. Wrap reorderable child in ReorderableItemView
  3. The ReorderableItemView index param shoud in order for all ReorderableItemView items.

@huhuang03 thanks a lot for the reply.

I checked the provided code but don't understand how to disable from the d&d mechanism a particular index.

Let say I want indeces 2,4 from my 9 items grid (0-8) to be disabled (not draggable, not targets and not moving around when other items drag and drop)

How can I do that ?