Answers for "check if app is in foreground or background flutter inside main"

0

flutter check if app is in foreground

class _MyHomePageState extends State<MyHomePage> 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();
  }
}
Posted by: Guest on April-24-2021

Code answers related to "check if app is in foreground or background flutter inside main"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language