Skip to content

Instantly share code, notes, and snippets.

@AbhishekDoshi26
Created July 28, 2021 07:38
Show Gist options
  • Save AbhishekDoshi26/9805ba0e9ccbd96a693bab033ebe382e to your computer and use it in GitHub Desktop.
Save AbhishekDoshi26/9805ba0e9ccbd96a693bab033ebe382e to your computer and use it in GitHub Desktop.
Added WidgetsBindingObserver
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