How to switch the screen smoothly?

Advertisements

I have three screens: 1, 2, and 3.
I want to switch from screen 2 to screen 3, but when I pop screen 2 and push screen 3, then it shows screen 1 for a while, then it shows screen 3, so is there any way to switch screens using pop after push or not?

this code not expectations

Navigator.push(
  context,
  MaterialPageRoute<Widget>(
    builder: (context) => widget,
  ),
);
Navigator.pop(context);

>Solution :

Using pushReplacement insted of push

Navigator.pushReplacement(
  context,
  MaterialPageRoute<Widget>(
    builder: (context) => widget,
  ),
);

Leave a Reply Cancel reply