setVariables function
execute the function
based on mounted
call setState if mounted
otherwise execute the function
normally
Implementation
void setVariables(bool mounted, StateSetter setState, VoidCallback function){
if(mounted){
setState(function);
}else{
function();
}
}