how to prevent stack children being overlapped in flutter

99 views Asked by At

Inside a stack I'm using multiple draggable widgets, but I want to prevent each draggable widget from overlapping each other.

this is my code:

InteractiveViewer(
            child: Container(
              constraints: BoxConstraints(
                minHeight: MediaQuery.of(context).size.height,
                minWidth: MediaQuery.of(context).size.width,
              ),
              child: Stack(
                  children: List.generate(listTable.length, (index) {
                var (b, a) =
                    getHW(listTable[index].noOFSeat, listTable[index].shape);
                double height = a + 50;
                double width = b + 50;

                return DraggableWidget(
                  child: Padding(
                    padding: const EdgeInsets.all(4.0),
                    child: GestureDetector(
                      onDoubleTap: () {
                        showAddTablePopUp(
                            table: listTable[index], index: index);
                      },
                      child: SizedBox(
                          height: height,
                          width: width,
                          child: listTable[index]),
                    ),
                  ),
                );
              })),
            ),
          )

DraggableWidget here is a combination of Positioned and GestureDetector.

how can I achieve this

0

There are 0 answers