如何检测持久性BottomSheet的解雇

时间:2019-08-12 22:37:47

标签: flutter dart

我正在尝试检测Persistent BottomSheet的关闭。我使用scaffoldKey.currentState.showBottomSheet打开工作表。 showBottomSheet仅返回一个PersistentBottomSheetController,您不能向其添加侦听器。我不知道还有什么方法可以检测纸页的收盘情况。我需要知道何时关闭工作表才能更改按钮的状态。

2 个答案:

答案 0 :(得分:0)

为此,您使用WillPopScope。底页即将关闭时,将调用onWillPop

// Place this widget somewhere in your bottom sheet.
WillPopScope(
  onWillPop: () async {
    // Return true if you want to allow the bottom sheet to be closed and false if not.
  },
  child: ..,
)

答案 1 :(得分:0)

您可以等待mEditText.setInputType(InputType.TYPE_CLASS_NUMBER);的属性closed暴露的未来

PersistentBottomSheetController