letsar / flutter_slidable

A Flutter implementation of slidable list item with directional slide actions.
MIT License
2.73k stars 591 forks source link

Slidable open Not effective ? #455

Open daijintaozz opened 10 months ago

daijintaozz commented 10 months ago

When I can't open ActionPanel for a long time.

Here is my main code:

ListView.builder(
                itemCount: myPositions.length,
                padding: EdgeInsets.zero,
                itemBuilder: (ctx, index) {
                  return GestureDetector(
                    onLongPress: () {
                       Slidable.of(context)?.openEndActionPane();
                    },
                    child: Slidable(
                      groupTag: MyPositionView.routeName,
                      key: ValueKey(index),
                      direction: Axis.horizontal,
                      endActionPane: ActionPane(
                        extentRatio: 0.2,
                        motion: const ScrollMotion(),
                        children: [
                          Builder(builder: (context) {
                            return Container(
                              margin: EdgeInsets.symmetric(vertical: 6.w),
                              child: Column(
                                children: [

                                  Expanded(
                                    child: TextButton(
                                      onPressed: () => deletePosition(index, context),
                                      style: TextButton.styleFrom(
                                        backgroundColor: const Color(0xff4077DE),
                                        foregroundColor: Colors.white,
                                      ),
                                      child: const Icon(Icons.delete_forever),
                                    ),
                                  ),
                                ],
                              ),
                            );
                          }),
                        ],
                      ),
                      child: MyWidget(),
                    ),
                  );
                },
              )

It is very unreasonable to ensure that the context can only be used with Slidable. of (context).