-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added Extension for router to get NestedAppRouter.
- Loading branch information
Showing
4 changed files
with
96 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
part of masamune; | ||
|
||
/// Create an extension method for [RefHasPage] to create nested routers. | ||
/// | ||
/// ネストされたルーターを作成するための[RefHasPage]の拡張メソッドを作成します。 | ||
extension MasamuneModelAppRefExtensions on RefHasPage { | ||
/// Create nested routers by passing [pages]. | ||
/// | ||
/// Pass to [Router.withConfig] to display nested pages. | ||
/// | ||
/// [pages]を渡すことによりネストされたルーターを作成します。 | ||
/// | ||
/// [Router.withConfig]に渡してネストされたページを表示してください。 | ||
/// | ||
/// ```dart | ||
/// final router = ref.router( | ||
/// initialQuery: HomePage.query(), | ||
/// pages: [ | ||
/// HomePage.query, | ||
/// ProfilePage.query, | ||
/// ], | ||
/// ); | ||
/// return Router.withConfig(router); | ||
/// ``` | ||
NestedAppRouter router({ | ||
required RouteQuery? initialQuery, | ||
required List<RouteQueryBuilder> pages, | ||
}) { | ||
return page.watch((ref) { | ||
return NestedAppRouter( | ||
initialQuery: initialQuery, | ||
pages: pages, | ||
); | ||
}); | ||
} | ||
} |
Oops, something went wrong.