Open nicolasvahidzein opened 2 years ago
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');
}
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');
}
),
);
}
},
@HammadBukhari
@hammadbukhari I need your help please.
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 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 thank you so much Clifton, i will try this tomorrow and revert back. Much appreciated.
doesn't work for me
doesn't work for me too :(
I have the same issue :(
does not work i currently SlidableController dismiss method does not anything.
It would be nice if the maintainer could look into this after all this time.
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.
Is the maintainer still working on this issue? We are all still waiting for this feature. Anyone reading this?
I guess not. It probably be better if we fork the repo and maintain it until he comes back
I guess not. It probably be better if we fork the repo and maintain it until he comes back
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',
),
I bumped into a similar issue, autoClose: false
worked for me.
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.