In the build() method of the FirstRoute widget,
update the onPressed() callback:

3. Return to the first route using Navigator.pop()

How do you close the second route and return to the first?
By using the Navigator.pop() method.
The pop() method removes the current Route from the stack of
routes managed by the Navigator.

To implement a return to the original route, update the onPressed()
callback in the SecondRoute widget:

Interactive example

Animate a widget across screens

Navigate with named routes