Created
July 28, 2021 07:38
-
-
Save AbhishekDoshi26/9805ba0e9ccbd96a693bab033ebe382e to your computer and use it in GitHub Desktop.
Added WidgetsBindingObserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class Home extends StatefulWidget { | |
const Home({Key? key}) : super(key: key); | |
@override | |
_HomeState createState() => _HomeState(); | |
} | |
class _HomeState extends State<Home> with WidgetsBindingObserver { | |
@override | |
void initState() { | |
super.initState(); | |
WidgetsBinding.instance!.addObserver(this); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold(); | |
} | |
@override | |
void dispose() { | |
WidgetsBinding.instance!.removeObserver(this); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment