简体   繁体   中英

How to close Slidable automatically in 1 second?

I am using flutter_slidable and it works well, but I would like to make that when you slide a item, automatically it returns at the original position (close) after 1 second. And only keep opened when a bool change. Is there any option or a way to do ir programatically? Thanks.

Please try to read the documentation, last section is talking about your need:

How can I open the Slidable programmatically? 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.

How can I dismiss the Slidable programmatically? Similar to opening or closing, you can dismiss the Slidable programmatically by calling the dismiss method of the SlidableState . If you want to use the dismiss method without allowing your user to slide to dismiss, you can set the dragDismissible parameter of the SlidableDismissal constructor to false.

You can use this with await Future.delayed(Duration(seconds: 1),(){ //open or close });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM