Future popAndPushNamed(BuildContext context, String routeName, { result })

Executes a simple transaction that both pops the current route off and pushes a named route into the navigator that most tightly encloses the given context.

If non-null, result will be used as the result of the route that is popped. Routes such as dialogs or popup menus typically use this mechanism to return the value selected by the user to the widget that created their route. The type of result, if provided, must match the type argument of the class of the current route. (In practice, this is usually "dynamic".)

Returns a Future that completes to the result value passed to pop when the pushed route is popped off the navigator.

Typical usage is as follows:

Navigator.popAndPushNamed(context, '/nyc/1776');


static Future<dynamic> popAndPushNamed(BuildContext context, String routeName, { dynamic result }) {
  final NavigatorState navigator = Navigator.of(context);
  return navigator.pushNamed(routeName);