I am trying to detect the closure of a Persistent BottomSheet. I open the sheet using the scaffoldKey.currentState.showBottomSheet. The showBottomSheet only returns a PersistentBottomSheetController which you can't add a listener to. I am not sure how else to detect the close of the sheet. I need to know when the sheet is closed to change the state of a button.
Asked
Active
Viewed 1,496 times
0
-
1So I had this problem in a recent problem and could detect when this sheet was removed by back button action but not when the bottom sheet was dragged down. I searched all i could and the library didn't really give any straight provision for that. The fix though was that i checked when the modal is within the page using a visibility detector package. https://stackoverflow.com/questions/51069712/how-to-know-if-a-widget-is-visible-within-a-viewport You can follow that link to see the package and how to install and use it. Hope this helps – Yalzeee Mar 12 '20 at 13:01
1 Answers
0
You can wait for the future exposed by attribute closed
of PersistentBottomSheetController
final controller = scaffoldKey.currentState.showBottomSheet(...);
await controller.closed

andrea689
- 624
- 6
- 15