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

Programmatically open slider #67

Closed
brotoo25 opened this issue May 8, 2019 · 14 comments
Closed

Programmatically open slider #67

brotoo25 opened this issue May 8, 2019 · 14 comments

Comments

@brotoo25
Copy link

brotoo25 commented May 8, 2019

Would like to present the side buttons to the user for a little while and then close it, all without any touch interactions.

@geekydiamond
Copy link

Or just a little peek so the user knows that there are buttons available via slide

@spedalilama
Copy link

Any update on this? I'm looking to do the same thing.

@vladbarash
Copy link

The readme has a note about doing this:

You can open or close the Slidable programmatically by calling the open or close method of the SlidableState. The easiest way get the SlidableState from a child is to call Slidable.of(context).

The open method has an optional parameter called actionType that let you choose which action pane to open.

However, I was not able to figure it out with these details. Has anyone been able to get this working?

@irishka90
Copy link

if i have a few sliders on screen (widget with slider and listview with sliders) can you give me example.
Call Slidable.of(context) always return null

@vladbarash
Copy link

@irishka90 I am experiencing the same issue, not able to figure it out using the documentation.

@Brazol
Copy link

Brazol commented Aug 28, 2019

I created a fork with peek option for Slidable (in peek feature branch). Just set peekOnInit and peekActionType. Maybe it will help someone.

https://github.com/Brazol/flutter_slidable/tree/feature/peek

@mjeffw
Copy link

mjeffw commented Sep 11, 2019

For those having trouble with Slidable.of(context) returning null, refer to this issue to make sure you aren't using it incorrectly. I had the same issue and eventually figured out what I was doing wrong.

#95

@tigrenok00
Copy link

Did anyone find a solution? I can close the slider via controoller.activeState?close() if it is open, however, the open() method does not work the same way for some reason

@brotoo25
Copy link
Author

brotoo25 commented Dec 2, 2019

Did anyone find a solution? I can close the slider via controoller.activeState?close() if it is open, however, the open() method does not work the same way for some reason

Slidable.of(context).open(
     actionType: SlideActionType.secondary,
);

Works for me.

@Purvik
Copy link

Purvik commented Jan 27, 2020

@brotoo25 I got that this is the way to programmatically open and close but what If I'm passing Function from its parent widget tree and assigning it's directly to onPress or onClick of action icon. How can I perform close?

@thearthurdev
Copy link

I created a fork with peek option for Slidable (in peek feature branch). Just set peekOnInit and peekActionType. Maybe it will help someone.

https://github.com/Brazol/flutter_slidable/tree/feature/peek

I tried using your fork. It didn't work either.
Could you provide an example on how to implement it or is it just a simple matter of setting the peekOnInit parameter to true?

@letsar
Copy link
Owner

letsar commented Jul 16, 2021

I think, this is now possible in the 1.0 version. You can get the SlidableController within a Slidable's child and make some actions programmatically.

@mflesh1
Copy link

mflesh1 commented Mar 9, 2022

Is there a working example of how to use the SlideableController?

@SameerGhaffar
Copy link

SameerGhaffar commented Dec 28, 2023

I Got the Solution.....
Slidable.of(context) is null because it is not taking correct context

here is the Solution

Widget slidable(int index) {
SlidableController? slider;
return Slidable(
key: ValueKey(index),
endActionPane: ActionPane(
motion: const ScrollMotion(),
children: [
Expanded(
child: slidableActionItem(
text: "Edit",
padding: 0,
onTap: () {
CategoryModel category = expenseProvider.categoryList[index];
context.push(child: AddCategory(isEdit: true, data: category));
Future.delayed(
Duration(milliseconds: 20),
() {
slider?.close();
},
);
},
),
),
Expanded(
child: slidableActionItem(
text: "Delete",
color: CColors.primary,
padding: 0,
onTap: () => onDelete(expenseProvider.categoryList[index].docId),
),
),
],
),
child: Builder(builder: (context) {
slider = Slidable.of(context)!;
return expenseBox(index);
}),
);
}

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

No branches or pull requests