From c995e96de4c09d1b84258c7a0c2b2d1b548e3170 Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Tue, 23 Aug 2022 08:38:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/home/home_page.dart | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 2998ba1..788f22f 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -22,7 +22,7 @@ bool plone=false; @override -class _HomePageState extends State { +class _HomePageState extends State with WidgetsBindingObserver{ @override void initState() { super.initState(); @@ -38,7 +38,23 @@ class _HomePageState extends State { plone =await Permission.phone.request().isGranted; setState(() {}); } - + void didChangeAppLifecycleState(AppLifecycleState state){ + super.didChangeAppLifecycleState(state); + switch (state){ + case AppLifecycleState.inactive: + print("1"); + break; + case AppLifecycleState.resumed: + print("2"); + break; + case AppLifecycleState.paused: + print("3"); + break; + case AppLifecycleState.detached: + print("4"); + break; + } + } @override Widget build(BuildContext context) { return Scaffold(