replaceScreen function
Replaces the current screen with a new screen.
The ReplaceScreen
function replaces the current screen with a new screen specified by the provided Screen
function.
context
: The context of the current screen.Screen
: The function that returns the widget representing the new screen.
Implementation
void replaceScreen(BuildContext context, Function() screen) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => screen()));
}