How to close Slidable automatically in 1 second? - flutter

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 });

Related

Auto hide bottom sheet when value changes from Firestore stream

I have a modal bottom sheet open waiting for a player to join a game via a code. I have a stream set up in my controller. When the player joins, I get the name of the other player. Once I get this name, I want to programmatically dismiss the bottom sheet so that the game can begin.
How can I do this, please?
If the modal is on top, you can simply call the following to close it:
Navigator.of(context).pop();
So, call this whenever you receive your data.

How to dismiss DraggableScrollableSheet in Flutter?

I try to make a pop up card when I press on a specific button and I use DraggableScrollableSheet because I want it starts minimized then the user can drag it up to maximize it.
so the question is there some way to dismiss this widget when the user press on the back screen or any other way to dismiss it?
I just call pop function inside the onTap callback function of the GestureDetector.
Navigator.pop(context);

How to pop bottom modal sheet when keyboard is hidden?

I want to pop my bottom modal sheet when my keyboard is hidden. But currently when I press back button keyboard gets hidden but bottom modal sheet remains opened.
I tried using package flutter_keyboard_visibility to detect if the keyboard is hidden and tried to pop the bottom navigation bar. But now when do that and press outside barrier to dismiss, there are two calls to Navigator.pop(context) method. One after hiding the keyboard and another built-in pop by the bottom modal sheet.
Can anyone help me find out how to achieve this?
Thanks.
I would do it the following way:
a) Return WillPopScope inside the Widget build method
b) As a callback for WillPopScope I will Navigator.pop(context)
You can also try the keyboard_visiblity plugin. This will provide you a callback easily.
Did you try using setState(() {}); ?
it will also helps for updating the state of screen

AVButton on a AVPlayerViewController Frame

I need to add a button exactly under the Close Button of the AVPlayer.
So I need to find the exact frame of this button for different screen sizes,
but I can not find the way to access this button.
Note: In the "Debug View Hierarchy" the button presented as "AVButton".
Officially there is no Close Button click event access, an engineer from Apple said about it here..https://forums.developer.apple.com/thread/20979

Which function is called when a screen is opened after popping from navigation stack?

I have 2 screens - screen A and screen B. I navigate from screen A to screen B.
I want to take some particular action when I am coming BACK to screen A by popping out screen B from the navigation stack.
I know I can use didUpdateWidge but I can't figure out an efficient way of doing it.
Is using Inherited Widget the correct way here?
Navigator.push[Named] returns a Future that completes when screen B pops. So add the code you want to execute after the pop to then.
Navigator.pushNamed(context, '/someRoute').then((_) {/* do stuff here */});
Try to use WillPopScope. This widget allows to catch back button press.