flutter_slidable icon indicating copy to clipboard operation
flutter_slidable copied to clipboard

Cannot dismiss tile on tap

Open nicolasvahidzein opened this issue 3 years ago • 18 comments

It seems many people are running into this issue that is hard to figure out:

Getting the slideaction to dismiss programmatically:

https://github.com/letsar/flutter_slidable/issues/31#issuecomment-880840889

this commenet does not work, can @letsar you please guide us by posting the proper procedure here or update the docs to show us how to accomplish this please?

Thank you so much.

nicolasvahidzein avatar Mar 27 '22 00:03 nicolasvahidzein

Inside my SlidableAction onPressed callback i have this code but the controller is returned null, how is this possible inside the widget. It's strange to me?

final controller = Slidable.of(context);

if (controller == null) {
    print('slidable controller is INDEED null');
}

nicolasvahidzein avatar Mar 27 '22 01:03 nicolasvahidzein

I found the issue, we need to pass the fresh context as mentionned in some of the issues on this repo, see "contexto" below.

However this uses the rightmost icon as the one that will expand and be used during the dismiss animation and that is not what we want.

How can we address that?

onPressed: (contexto) {
									
_swipedAction('delete');

print('this should close');

final controller = Slidable.of(contexto);

if (controller == null) {

print('slidable controller is INDEED null');

} else {

print('slidable controller is NOT null');

controller.dismiss(
	ResizeRequest(
		const Duration(milliseconds: 300),
		() {
			print('Dismiss from Button');
		}
	),
);

}

},

nicolasvahidzein avatar Mar 27 '22 01:03 nicolasvahidzein

@HammadBukhari

nicolasvahidzein avatar Mar 27 '22 01:03 nicolasvahidzein

@hammadbukhari I need your help please.

nicolasvahidzein avatar Mar 27 '22 01:03 nicolasvahidzein

I uploaded a demo video of what is happening:

https://youtube.com/shorts/XIdIaTwrtt4?feature=share

When we press on the left item contained in an endActionPane and trigger a programmatic onDismiss action, it is the blue (right most icon) that is expanded when the onDismiss action is triggered and not the icon (the red delete one) that was tapped.

How can we fix this please?

nicolasvahidzein avatar Mar 27 '22 02:03 nicolasvahidzein

@nicolasvahidzein this is what I did to dismiss a list item on tap.

endActionPane: ActionPane(
  motion: const BehindMotion(),
  
  dismissible: DismissiblePane(onDismissed: () {}),
  
  children: [
    SlidableAction(
      autoClose: false,
      onPressed: (context) {
        final controller = Slidable.of(context);
        controller?.dismiss(
          ResizeRequest(
              const Duration(milliseconds: 300),
              () => comments
                  ?.remove(comments[index])),
          duration:
              const Duration(milliseconds: 300),
        );
      },
      backgroundColor: Colors.red,
      foregroundColor: Colors.white,
      icon: Icons.delete,
      label: 'Delete',
    ),
  ]
)

cliftonscott avatar Apr 12 '22 01:04 cliftonscott

@cliftonscott thank you so much Clifton, i will try this tomorrow and revert back. Much appreciated.

nicolasvahidzein avatar Apr 12 '22 02:04 nicolasvahidzein

doesn't work for me

caseyryan avatar Jun 03 '22 15:06 caseyryan

doesn't work for me too :(

Zechst avatar Jul 28 '22 15:07 Zechst

I have the same issue :(

bakatsuyuki avatar Aug 18 '22 02:08 bakatsuyuki

does not work i currently SlidableController dismiss method does not anything.

fullflash avatar Nov 21 '22 12:11 fullflash

It would be nice if the maintainer could look into this after all this time.

nicolasvahidzein avatar Nov 21 '22 20:11 nicolasvahidzein

it's not working. nothing is happening! the print inside the resize request doesn't show so it doesn't even get into the ondimissed() function and it doesn't remove anything or show any dismissal animation i have been on this issue for 3 days now.

naddamuhamed avatar Dec 06 '22 19:12 naddamuhamed

Is the maintainer still working on this issue? We are all still waiting for this feature. Anyone reading this?

nicolasvahidzein avatar Feb 20 '23 22:02 nicolasvahidzein

I guess not. It probably be better if we fork the repo and maintain it until he comes back

Zechst avatar Feb 21 '23 11:02 Zechst

I guess not. It probably be better if we fork the repo and maintain it until he comes back

Zechst avatar Feb 21 '23 11:02 Zechst

autoClose needs to be false. This code works for me

SlidableAction(
                      autoClose: false,
                      borderRadius: BorderRadius.circular(12),
                      onPressed: (context) {
                        final controller = Slidable.of(context);
                        controller?.dismiss(
                          ResizeRequest(
                              const Duration(milliseconds: 300), () => {}),
                          duration: const Duration(milliseconds: 300),
                        );
                      },
                      backgroundColor: const Color(0xFFFE4A49),
                      foregroundColor: Colors.white,
                      icon: Icons.delete,
                      label: 'Delete',
                    ),

liam-duan avatar Feb 28 '23 04:02 liam-duan

I bumped into a similar issue, autoClose: false worked for me.

nomtats avatar Apr 03 '24 06:04 nomtats