Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set SlidableController.activeState.open() with onTap #39

Closed
DARdk opened this issue Oct 29, 2018 · 15 comments
Closed

Set SlidableController.activeState.open() with onTap #39

DARdk opened this issue Oct 29, 2018 · 15 comments
Assignees
Labels
enhancement New feature or request

Comments

@DARdk
Copy link

DARdk commented Oct 29, 2018

Thank you for an awesome Flutter implementation!
Is it possible to open the drawer and show all the iconslider actions through a onTap event on the Slidable? See the scenario on the two images below:
screenshot

Currently the only example that is given is to close the drawer as seen in Issue 33:
#33
However, if the Slidable is not in an activestate, the output of:
slidableController.activeState is null, and hence I am not able to do:
slidableController.activeState.open() because it will simply say:
"The method 'open' was called on null"

See the example code below:
codeexample

@letsar letsar self-assigned this Oct 29, 2018
@letsar letsar added the enhancement New feature or request label Oct 29, 2018
@letsar
Copy link
Owner

letsar commented Oct 29, 2018

I see. This widget wasn't created with this kind of feature in mind. I need to rewrote some parts in order to be animated by sliding or with a call to a function.
For the moment, you can call Slidable.of(context) inside the child of a Slidable to get its state and call open(). But you won't get any animation and you won't be able to tell whether you want to open the primary or secondary actions.
I won't be able to do it now, but give me some time and I will do it 🙂.

@DARdk
Copy link
Author

DARdk commented Oct 30, 2018

Thank you for the prompt answer letsar.
I did not have any luck with your suggestion (my child of Slidable is a ListTile). The Slidable.of(context) was null in all cases.
However, I will just implement a in-app guidance, and keep this functionality as a future feature. Thank you for considering this enhancement in a future version.

@letsar
Copy link
Owner

letsar commented Oct 30, 2018

If Slidable.of(context) was null, it's maybe because the context is a parent of the Slidable. It can be related to
https://stackoverflow.com/questions/51304568/scaffold-of-called-with-a-context-that-does-not-contain-a-scaffold/51304732

Thank you, I will keep you posted on my advancement 🙂 .

@miDeb
Copy link
Contributor

miDeb commented Nov 11, 2018

I've implemented a solution for this on my fork, so if you could have a look...
Note that I've also made some other changes.
Perhaps I've broken something😁.

@DARdk
Copy link
Author

DARdk commented Nov 16, 2018

Amazing! Thanks both. I added your version to my pubspec.yaml, and change from Slidable to Slidable.builder. Then wrapped the child of Slidable.builder inside a builder like:
child: new Builder(builder: (contextNew) => new Column(....)
And it perfectly animates the slide-effect for my secondaryactions during onTap.
However, somehow I need to slide it the first time to make it "recognize" the object, THEN a onTap will slide it out. But If I entered the page and directly press it: Nothing happens... Any clue?
Thanks a lot.

@letsar
Copy link
Owner

letsar commented Nov 16, 2018

Great. I've been working on a complete refactor of the API (you can see the work in progress in the https://github.com/letsar/flutter_slidable/tree/feature/refactor branch) and I added the feature to animate on when opening. I will keep you posted on the advancement.

@miDeb
Copy link
Contributor

miDeb commented Nov 17, 2018

@DARdk are you calling open() without the actionType?

@DARdk
Copy link
Author

DARdk commented Nov 18, 2018

@miDeb Yes, I did not add the actionType. By adding it as: Slidable.of(context).open(actionType: SlideActionType.secondary);
It works every time! Thanks, this is perfect

@enzoftware
Copy link

@DARdk thanks so much, you save me!

@ZionPi
Copy link

ZionPi commented Dec 13, 2019

How to check if the Slidable Item is opened or closed?

@letsar
Copy link
Owner

letsar commented Nov 8, 2020

Closing as this is resolved

@letsar letsar closed this as completed Nov 8, 2020
@armandojimenez
Copy link

How can I check if the slideable is already open to close it?

@saigopin
Copy link

saigopin commented Dec 6, 2021

@armandojimenez any solution?

@armandojimenez
Copy link

armandojimenez commented Dec 6, 2021

I use this:

if (Slidable.of(context)!.renderingMode == SlidableRenderingMode.none) {
              Slidable.of(context)!.open(actionType: SlideActionType.secondary);
} else {
              Slidable.of(context)!.close();
}

When I tap the cell, it opens or close depending if it's already open. Do only weird issue, is that if I open it via a tap, and them try to close it by sliding, it does without animation, and looks weird. But if you closed it back by tap it works fine.

@gopibathini
Copy link

@armandojimenez what should instead of rendering mode in latest null satety version 1.0.0. I want to open the slider at a time on tapping the list item , when i tap on second item , first item just closes its slide but second item not opening it slide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants