replaceScreen function

void replaceScreen(
  1. BuildContext context,
  2. dynamic screen()
)

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()));
}