我正在使用showModalBottomSheet展示一个模态材料设计底板。
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
...我想让这张底纸自动合上(爆裂?)当Flutter Android应用程序暂停时(例如,用户正在轻敲主页按钮)。
我该怎么做呢?
发布于 2021-09-16 09:08:16
检查WidgetsBindingObserver:https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver-class.html。您可以在您的模态小部件中扩展它,并在应用程序状态暂停时调用pop()。
发布于 2021-09-16 09:07:42
Code to detect if user pressed home / tab on flutter?可能是一个可行的解决方案?
如果您检测到应用程序生命周期中的暂停更改,那么您是否可以创建一个navigator.of(context).pop?
https://stackoverflow.com/questions/69205430
复制相似问题