I have a global function that I call from almost all screens of my app. I am passing context to it. I just want to know if there is a way to refresh the page from which the global function is called depending on context passed to the function?
appResumedPausedLogic(context,[bool isVisitPage]){
SystemChannels.lifecycle.setMessageHandler((msg)async{
if(msg=='AppLifecycleState.resumed' )
{
print("------------------------------------ App Resumed-----------------------------");
var serverConnected= await checkConnectionToServer();
if(globals.globalCameraOpenedStatus==false)
if(serverConnected!=1){
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => OfflineHomePage()));
}
else{
Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage()));
}
}
if(msg=='AppLifecycleState.paused' ){
if(globals.globalCameraOpenedStatus==false)
locationThreadUpdatedLocation=false;
}
});
}
My global function redirects users to offline home/home page depending on availability of internet when app is resumed currently. I want it to refresh the currently active screen.
Thanks in advance!
I once used this workaround for a floatingActionButton that reloaded the active page;
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) => super.widget));
just Simple use
setState(() {});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With