As you know in last article I told how to know when our app is in background. We will be using that thing in this article so I recommend you guys to once check that article as it will give you a overview how we knowing that our app is in back-ground and also some other useful information is there.
So using previous article we will know when our app is in background and using that information we will Tigger our app to make a bubble icon. This the logical part and it’s that simple but finding out the code harder part here.
class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
...
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.inactive:
print("Inactive");
break;
case AppLifecycleState.paused:
print("Paused");
break;
case AppLifecycleState.resumed:
print("Resumed");
break;
case AppLifecycleState.suspending:
print("Suspending");
break;
}
...
}
So this code will help us to find if our app is in back-ground , we will be writing our bubble icon code in Paused section.