pushNamed<E> method

Future<E?> pushNamed<E>(
  1. String path, [
  2. TransitionQuery? transitionQuery
])

Finds a RouteQuery that matches the path in the list of pages passed to AppRouter.pages and transitions to that page.

The method of page transition can be specified with transitionQuery.

You can wait until the page is destroyed by the pop method with the return value Future.

In doing so, it can also receive the object passed by pop.

AppRouter.pagesに渡したページリストからpathに当てはまるRouteQueryを探し出しそちらのページに遷移します。

ページ遷移の方法をtransitionQueryで指定可能です。

戻り値のFuturepopメソッドでページが破棄されるまで待つことができます。

また、その際popで渡されたオブジェクトを受け取ることができます。

Implementation

Future<E?> pushNamed<E>(
  String path, [
  TransitionQuery? transitionQuery,
]) async {
  for (final page in _config.pages) {
    final resolved = page.resolve(path);
    if (resolved != null) {
      return push<E>(
        resolved,
        transitionQuery,
      );
    }
  }
  throw Exception("No $path found.");
}