flutter_slidable icon indicating copy to clipboard operation
flutter_slidable copied to clipboard

How can I close Slidable if I don't use SlidableAction(autoColose=true)

Open KhaiHOK38 opened this issue 1 year ago • 2 comments

Slidable( enabled: isEnableSlidable, closeOnScroll: isCloseSlid, key: const ValueKey(0), endActionPane: ActionPane( dragDismissible: isCloseSlid, motion: const BehindMotion(), children: actionButton( status: widget.leaveRequest.status, leaveRequest: widget.leaveRequest, context: context), ), child: LeaveCardWidget( leaveRequest: widget.leaveRequest, isHaveAction: isEnableSlidable, ), ),

KhaiHOK38 avatar May 23 '23 07:05 KhaiHOK38

You can use Slidable.of(context)?.close() to close it. Make sure you use the context beneath the SlidableAction action, for example:

SlidableAction(
  autoClose: false,
  onPressed: (BuildContext context) async {
    final slidableController = Slidable.of(context);

    await showDialog<String>(
      context: context,
      builder: (BuildContext slContext) =>
          CancelBookingConfirmationDialog(
        onConfirm: () {
          print(">Confirm booking!");
        },
        onCancel: () {
          // Close slidable control
          slidableController?.close();
        },
      ),
    );
  },
  backgroundColor: ColorTheme.rufous,
  foregroundColor: Colors.white,
  label: t.app.cancelBooking,
),

alanrubin avatar Jul 10 '23 11:07 alanrubin

You can use CustomSlidableAction instead of SlideableAction

chuvanhoang888 avatar Nov 06 '23 07:11 chuvanhoang888