📌  相关文章
📜  颤动检查应用程序是否在前台 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:19.088000             🧑  作者: Mango

代码示例1
class _MyHomePageState extends State with WidgetsBindingObserver {
  late AppLifecycleState _notification; 
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    setState(() {
      _notification = state;
    });
  }

  @override
  initState() {
    super.initState();
    WidgetsBinding.instance!.addObserver(this);
    ...
  }

  @override
  void dispose() {
    WidgetsBinding.instance!.removeObserver(this);
    super.dispose();
  }
}