07-21-2023, 08:25 PM
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.
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.