replaceNamed<E> method
Finds a RouteQuery that matches the path
in the list of pages passed to AppRouter.pages and replaces the currently displayed page with 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
で指定可能です。
戻り値のFutureでpopメソッドでページが破棄されるまで待つことができます。
また、その際popで渡されたオブジェクトを受け取ることができます。
Implementation
Future<E?> replaceNamed<E>(
String path, [
TransitionQuery? transitionQuery,
]) async {
for (final page in pages) {
final resolved = page.resolve(path);
if (resolved != null) {
return replace<E>(
resolved,
transitionQuery,
);
}
}
throw Exception("No $path found.");
}