【发布时间】:2018-08-18 13:34:57
【问题描述】:
想象如下创建一个底部工作表:
final PersistenBottomSheetController bottomSheetController = showBottomSheet(...);
我如何在关闭该底部表时执行逻辑?
【问题讨论】:
想象如下创建一个底部工作表:
final PersistenBottomSheetController bottomSheetController = showBottomSheet(...);
我如何在关闭该底部表时执行逻辑?
【问题讨论】:
这对于 Flutter 小部件来说有点单调:bottomSheetController.closed 在关闭底部工作表时返回 Future,这允许这种逻辑:
bottomSheetController.closed.then((value) {
// this callback will be executed on close
});
也可以与 await 一起使用:
await bottomSheetController.closed;
// code below this call will get executed upon close
【讨论】:
final PersistentBottomSheetController<dynamic> bottomSheetController = scaffoldKey.currentState!.showBottomSheet((context) {
return Container();
});
await bottomSheetController.closed.then((value) {
// the code for working on drawer close
});
【讨论】: