Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
fa4c542
Added NestedNavigationShellRoute, to support building nested persiste…
tolo Sep 26, 2022
76b17ae
Added example for NestedNavigationShellRoute.
tolo Sep 26, 2022
7612a55
Formatting.
tolo Sep 27, 2022
62574bd
Formatting.
tolo Sep 27, 2022
850f41a
Removed NestedNavigationShellRoute and replaced it with new field `ne…
tolo Sep 27, 2022
1c04588
Rebased onto upstream/main.
tolo Sep 27, 2022
1db6bba
Fixed typos.
tolo Sep 27, 2022
6028c90
Updated documentation of property navigatorKey on ShellRoute.
tolo Sep 28, 2022
5f2e995
Added another unit test for ShellRoute with nestedNavigationBuilder.
tolo Sep 28, 2022
461efd9
Updated example to use nested ShellRoutes instead of creating nested …
tolo Sep 28, 2022
0315e1a
Refactored support for nested stateful navigation - introduced new ro…
tolo Sep 30, 2022
510ec34
Some renaming.
tolo Sep 30, 2022
e82647a
Changed the way currentLocation is calculated since it currently does…
tolo Sep 30, 2022
e38fa32
Minor cleanup and refactoring.
tolo Sep 30, 2022
f38b9bf
Renamed StackedNavigationScaffold to StackedNavigationShell.
tolo Sep 30, 2022
89f1dd7
Added more tests for PartitionedShellRoute.
tolo Sep 30, 2022
3a00a54
Added more detail
tolo Sep 30, 2022
b0a6264
Fixed analyzer issue and code style issue.
tolo Sep 30, 2022
b729d64
Merge branch 'main' of github.com:flutter/packages into nested-persis…
johnpryan Sep 30, 2022
3b3909f
Fix test
johnpryan Sep 30, 2022
f0b2a1b
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 2, 2022
eb6d4d3
Introduced the method `navigatorKeyForChildRoute` on ShellRouteBase t…
tolo Oct 2, 2022
016be76
Added a canPop test for PartitionedShellRoute (by replacing a duplica…
tolo Oct 2, 2022
4ae26d7
Updated implementation of popRoute be in sync with canPop.
tolo Oct 2, 2022
4a9889a
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 3, 2022
1f3f01a
Updated documentation of PartitionedShellRoute with examples.
tolo Oct 3, 2022
3b38641
Updated documentation for builder and pageBuilder fields of ShellRout…
tolo Oct 3, 2022
d701ab5
Fixed documentation typos and minor refactoring (renaming).
tolo Oct 3, 2022
bb6240d
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 3, 2022
245d47b
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 4, 2022
bda571b
Refactored PartitionedShellRoute and renamed to StatefulShellRoute.
tolo Oct 7, 2022
da1ea0b
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 7, 2022
59c19e7
Some refactoring (mostly naming and code readability).
tolo Oct 10, 2022
723de76
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 10, 2022
4c0a91d
Fixed CI analyzer issue.
tolo Oct 10, 2022
7556965
Removed animation support from StatefulNavigationShell and refactored…
tolo Oct 11, 2022
ee9bde9
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 11, 2022
e9a7029
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 13, 2022
59a6b05
Updated changelog (replaced PartitionedShellRoute with StatefulShellR…
tolo Oct 13, 2022
06ab1e9
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 14, 2022
1b877c8
Implemented equality in StatefulShellRouteState and ShellRouteBranchS…
tolo Oct 22, 2022
e542a05
Documentation updates.
tolo Oct 23, 2022
2215a51
Removed field navigatorKeys from StatefulShellRoute and fixed issue w…
tolo Oct 25, 2022
b180653
Removed the use of top GoRouterState as a way of getting the current …
tolo Oct 25, 2022
8fdfb82
Updated example to use the default constructors of StatefulShellRoute…
tolo Oct 25, 2022
9240ea4
Added check when pushing a new route to ensure you cannot push a rout…
tolo Oct 25, 2022
93bce8e
Minor renaming.
tolo Oct 25, 2022
20dc0c6
Added restorationScopeId to ShellRouteBranch and ShellRoute.
tolo Oct 25, 2022
376e80f
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 25, 2022
2b2ff91
Added support for maintaining any extra navigation object passed to t…
tolo Oct 27, 2022
5c9fe04
Moved NEXT info 5.2.0 in changelog
tolo Oct 28, 2022
81e1296
Added assertion in RouteConfiguration for field defaultLocation of Sh…
tolo Oct 28, 2022
59e3b66
Added field preloadBranches to StatefulShellRoute, to enable support …
tolo Oct 28, 2022
8636bf8
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 28, 2022
1c509f1
Various updates from PR feedback:
tolo Oct 28, 2022
42c7b7d
Changed the way switching between route branches works - switching is…
tolo Oct 29, 2022
62e7fc1
Reverted restriction around pushing sub-routes of a StatefulShellRoute.
tolo Oct 30, 2022
9a7069a
Doc fixes/updates for StatefulShellRoute.
tolo Oct 30, 2022
ae48ede
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Oct 30, 2022
141fdc1
Added handling of redirection when switching and preloading route bra…
tolo Nov 4, 2022
b6b289f
Reintroduced validation of defaultLocation of StatefulShellRoute (in …
tolo Nov 4, 2022
4d05d99
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Nov 4, 2022
d4edd47
Removed replaceMatchList in GoRouterDelegate (using setNewRoutePath i…
tolo Nov 4, 2022
7b9de47
Added additional test for redirection with StatefulShellRoute.
tolo Nov 4, 2022
703815c
Updated ShellRouteBranch to accept list of routes instead of only a s…
tolo Nov 9, 2022
9f88928
Added support for resetting StatefulShellRouteState.
tolo Nov 9, 2022
5ca533d
Renamed and changed signature of the navigator getters of StatefulShe…
tolo Nov 9, 2022
f5f0ecb
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Nov 9, 2022
4a2eac3
Added temporary workaround due to duplication of encodedParams of Rou…
tolo Nov 18, 2022
fc7bd54
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Nov 18, 2022
a65f9df
Refactoring of StatefulShellRoute to support dynamic branches, as wel…
tolo Nov 29, 2022
816acb2
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Nov 29, 2022
ee2a845
Introduced an internal branch Navigator proxy widget to make the API …
tolo Nov 30, 2022
89b82c5
Renamed StatefulShellRoute example file to stateful_shell_route.dart
tolo Nov 30, 2022
90b9d62
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Nov 30, 2022
7392264
Reduced unnecessary rebuilds of child Widgets of StatefulShellRoute, …
tolo Dec 1, 2022
c0253f6
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 1, 2022
2c4afa1
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 2, 2022
845c052
Minor refactoring - moved StatefulShellBranchResolver to route.dart.
tolo Dec 2, 2022
193a267
Fixed issue in StatefulShellBranch.isBranchFor (accidental use of inc…
tolo Dec 8, 2022
37c4969
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 8, 2022
c562482
Reverted workaround regarding pop.
tolo Dec 8, 2022
38b5772
Equality fix in UnmodifiableRouteMatchList.
tolo Dec 8, 2022
db22bac
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 8, 2022
d8d1641
Corrected invalid sample file names.
tolo Dec 13, 2022
4c4b7b0
Additional rebuild improvement.
tolo Dec 13, 2022
f08f548
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 13, 2022
6f1b047
Minor documentation fix.
tolo Dec 14, 2022
07ee030
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 14, 2022
9ffff5c
Removed AppRouterProvider from sample code.
tolo Dec 15, 2022
e9d40ee
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Dec 15, 2022
0ea48cb
Update packages/go_router/CHANGELOG.md
tolo Dec 21, 2022
4abcaa9
Update packages/go_router/CHANGELOG.md
tolo Dec 21, 2022
ce23558
Update packages/go_router/CHANGELOG.md
tolo Dec 21, 2022
351ceb2
Update packages/go_router/lib/src/route.dart
tolo Dec 21, 2022
4cb0f1e
Partially reverted the StatefulShellRoute API back to the previous so…
tolo Jan 5, 2023
e6a4f71
Documentation updates and some renaming.
tolo Jan 5, 2023
873bf34
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Jan 5, 2023
5b668f8
Fix for error in _preloadShellBranchNavigator due to recent changes i…
tolo Jan 5, 2023
565c3cd
Updated _routeMatchLookUp to handle reused/cached Navigators.
tolo Jan 19, 2023
5ee1a8f
Added support for resetting state for single branch (resetBranch).
tolo Jan 19, 2023
358551f
Added examples of pushing modal routes above the stateful shell.
tolo Jan 19, 2023
f9a2608
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Jan 19, 2023
87211aa
Alternative StatefulShellRoute implementation, were either a builder …
tolo Feb 7, 2023
257a272
Extracted construction of StatefulNavigationShell and Navigators out …
tolo Feb 16, 2023
08148e5
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Feb 16, 2023
c18941f
Added NavigatorObserver support to StatefulShellRoute.
tolo Feb 16, 2023
b1ce762
Refactored the builder methods of the shell route classes to improve …
tolo Feb 16, 2023
75e43d0
Various refactoring.
tolo Feb 17, 2023
9f54b4e
Minor renaming.
tolo Feb 17, 2023
1226f44
Updated equals method in GoRouterState to properly compare Map fields.
tolo Feb 19, 2023
881be86
Updated handling of RouteMatch lookup for pages/routes (replaced Expa…
tolo Feb 19, 2023
6bbbd29
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Feb 19, 2023
fd5412f
Add type annotation to listEquals
tolo Feb 23, 2023
a5234a6
Moved RouteNavigatorBuilder into builder.dart and made private.
tolo Feb 26, 2023
b9428cb
Moved StatefulNavigationShell and support classes into route.dart and…
tolo Feb 26, 2023
ee047c8
Refactoring of StatefulShellRoute and related classes to simplify bui…
tolo Mar 8, 2023
ddc71f0
Re-introduced proper validation of parent Navigator keys for routes i…
tolo Mar 8, 2023
5041bea
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Mar 8, 2023
01cce04
Updated constructors in sample code to use super parameters.
tolo Mar 8, 2023
9315373
Removed preload support.
tolo Mar 10, 2023
89341ef
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Mar 10, 2023
2c298cd
Refactored state management for StatefulShellRoute.
tolo Mar 13, 2023
4c22b53
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Mar 13, 2023
a7d419f
Moved branch state management back into StatefulShellRoute and simpli…
tolo Mar 31, 2023
7285788
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Mar 31, 2023
9983887
Renamed StatefulShellRoute to StackedShellRoute
tolo Apr 6, 2023
ad43837
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Apr 6, 2023
3a83007
Merge remote-tracking branch 'upstream/main' into nested-persistent-n…
tolo Apr 6, 2023
ec6722c
Update packages/go_router/lib/src/route.dart
tolo Apr 15, 2023
9bb0da9
Update packages/go_router/lib/src/route.dart
tolo Apr 15, 2023
a1c7a8f
Update packages/go_router/lib/src/route.dart
tolo Apr 15, 2023
477b47c
Removed StackedShellRouteState and moved functionality into StackedNa…
tolo Apr 20, 2023
7f25f0c
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Apr 20, 2023
6f35636
Doc updates - removed/replaced references to StackedShellRouteState.
tolo Apr 20, 2023
bb5c08f
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo Apr 28, 2023
16c095c
Refactoring due to review feedback.
tolo Apr 29, 2023
a18a5a5
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo May 1, 2023
abbd01b
Removed matchListEquals from RouteMatchList and replaced with the now…
tolo May 1, 2023
0f36623
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo May 1, 2023
316cf8c
Removed obsolete copy method from RouteMatchList.
tolo May 4, 2023
79a0c63
Updated StatefulNavigationShell to only save the part of the RouteMat…
tolo May 4, 2023
3696448
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo May 4, 2023
763b136
Minor sample code refactoring (documentation and renaming).
tolo May 8, 2023
2f48831
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo May 8, 2023
709ee7a
Apply suggestions from code review
tolo May 10, 2023
bb7fd9e
Implemented review feedback
tolo May 10, 2023
9eaf1af
Some additional cleanup
tolo May 10, 2023
527a806
Merge branch 'main' of github.com:flutter/packages into nested-persis…
tolo May 10, 2023
86a72e1
Merge branch 'main' into nested-persistent-navigation
johnpryan May 17, 2023
57b761f
Apply suggestions from code review
tolo May 18, 2023
85fa0b6
Apply suggestions from code review.
tolo May 18, 2023
d75c5e2
Reintroduced resetLocation parameter to goBranch.
tolo May 18, 2023
bd1c018
Merge remote-tracking branch 'upstream/main' into nested-persistent-n…
tolo May 18, 2023
c13cd71
Renamed parameter resetLocation in goBranch to initialLocation.
tolo May 19, 2023
c7b1295
Fixed future deprecation warning workaround
tolo May 19, 2023
0f842ee
Merge remote-tracking branch 'upstream/main' into nested-persistent-n…
tolo May 19, 2023
80c396f
Merge branch 'main' into nested-persistent-navigation
chunhtai May 19, 2023
04b549a
Merge branch 'main' into nested-persistent-navigation
johnpryan May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Doc fixes/updates for StatefulShellRoute.
  • Loading branch information
tolo committed Oct 30, 2022
commit 9a7069a0e2e8df180ba6c83f52f1bc8aa5b609cf
38 changes: 24 additions & 14 deletions packages/go_router/lib/src/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,11 @@ class ShellRoute extends ShellRouteBase {
/// this shorthand constructor, the [GoRoute.parentNavigatorKey] will be used
/// as the Navigator key.
///
/// Like [ShellRoute], you can provide a builder ([ShellRouteBranchState]) and
/// pageBuilder ([ShellRoutePageBuilder]) when creating a StatefulShellRoute.
/// However, StatefulShellRoute differs in that the builder is mandatory and the
/// pageBuilder will be used in addition to the builder. The child parameters of
/// the builders are also a bit different, even though this should normally not
/// affect how you implemented the builders.
/// Like [ShellRoute], you can provide a [builder] and [pageBuilder] when
/// creating a StatefulShellRoute. However, StatefulShellRoute differs in that
/// the builder is mandatory and the pageBuilder will be used in addition to the
/// builder. The child parameters of the builders are also a bit different, even
/// though this should normally not affect how you implemented the builders.
///
/// For the pageBuilder, the child parameter will simply be the stateful shell
/// already built for this route, using the builder function. In the builder
Expand All @@ -532,12 +531,23 @@ class ShellRoute extends ShellRouteBase {
/// wrapper Widget that provides access to the current [StatefulShellRouteState]
/// associated with the route (via the method [StatefulShellRoute.of]). That
/// state object exposes information such as the current branch index, the state
/// of the route branches etc.
/// of the route branches etc. It is also with the help this state object you
/// can change the active branch, i.e. restore the navigation stack of another
/// branch. This is accomplished using the method
/// [StatefulShellRouteState.goBranch]. For example:
///
/// For implementations where greater control is needed over the layout and
/// animations of the Navigators, the child parameter in builder can be ignored,
/// and a custom implementation can instead be built by using the Navigators
/// (and other information from StatefulShellRouteState) directly. For example:
/// ```
/// void _onBottomNavigationBarItemTapped(BuildContext context, int index) {
/// final StatefulShellRouteState shellState = StatefulShellRoute.of(context);
/// shellState.goBranch(index);
/// }
/// ```
///
/// Sometimes you need greater control over the layout and animations of the
/// branch Navigators. In such cases, the child argument in the builder function
/// can be ignored, and a custom implementation can instead be built using the
/// branch Navigators (see [StatefulShellRouteState.navigators]) directly. For
/// example:
///
/// ```
/// final StatefulShellRouteState shellState = StatefulShellRoute.of(context);
Expand All @@ -551,7 +561,7 @@ class ShellRoute extends ShellRouteBase {
/// BottomNavigationBar with two tabs is used, and each of the tabs gets its
/// own Navigator. A container widget responsible for managing the Navigators
/// for all route branches will then be passed as the child argument
/// of the [builder] function.
/// of the builder function.
///
/// ```
/// final GlobalKey<NavigatorState> _tabANavigatorKey =
Expand Down Expand Up @@ -609,8 +619,8 @@ class ShellRoute extends ShellRouteBase {
/// ```
///
/// When the [Page] for this route needs to be customized, you need to pass a
/// function for [pageBuilder]. Note that this page provider doesn't replace
/// the [builder] function, but instead receives the stateful shell built by
/// function for pageBuilder. Note that this page builder doesn't replace
/// the builder function, but instead receives the stateful shell built by
/// [StatefulShellRoute] (using the builder function) as input. In other words,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember things are this way for a reason, but I forgot why. Can you remind me again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah is it so that we can wrap a StatefulNavigationShell in between the page and the child?

If so I suggest we give them (builder/pageBuilder) a different name, The constructor can take these parameter and wire it up to only use the pageBuilder in the super. That way the builder.dart doesn't need to know these to build the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly, and thus the builder is always required. And the pageBuilder is just used for customising the Page for the already built (and wrapped) shell. At one point I called pageBuilder pageProvider instead, but after feedback I changed it back to pageBuilder. But it might be good with different names that would make the purpose of the builders clearer. Some possible names for builder might perhaps be shellBuilder or shellWidgetBuilder.

Regarding wiring up to use only the pageBuilder in the constructor StatefulShellRoute, I'm not sure about how to accomplish this in a clean way (if I understood you correctly that is), since builder.dart contains a lot of logic internally for default pageBuilder implementation as well as building the StatefulNavigationShell and the Navigator etc. Information such as PopPageCallback, RouteMatchList, page stack etc would have to be passed to the pageBuilder in that case, which might not be optimal. So the question is what would be gained by doing this (again -maybe I misunderstood something)? But I'll have to look at this a bit closer.

Copy link
Contributor

@chunhtai chunhtai Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My general concerns are we should avoid leaking out the implementation of StatefulShellRoute, Ideally, classes outside this file, e.g. RouteBuilder, should only use the API of GoRoute and ShellRouteBase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I guess I can understand that concern from one perspective on API and SRP etc, depending somewhat on the intended responsibility of different parts of GoRouter. However, a lot of the implementation details and behaviour related to GoRoute and ShellRoute are already delegated to most of the core classes of GoRouter. If you look at the primary responsibility of each class, it feels like RouteBuilder already handles most of the actual implementation details related to the building of widgets, pages and navigators, and thus would seem to be a good place to handle StatefulNavigationShell. To me it feels like the RouteBase classes are more like light-weight abstractions of a routes, whose primary purpose is to provide a clear and simple public API. But I may be wrong here of course, and might miss some part of the bigger picture.

One downside though of moving implementation details to StatefulShellRoute is that it would add dependencies to internal classes and types in GoRouter, that would then leak out in the public API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For builder and pageBuilder, I am still a bit confused about the reason the builder need to be required. If only uses pageBuilder, couldn't the child be the Navigator wrapped in StatefulNavigationShell?

a lot of the implementation details and behaviour related to GoRoute and ShellRoute are already delegated to most of the core classes of GoRouter

That is true, but we should not make it worse.

is that it would add dependencies to internal classes and types in GoRouter,

I think you meant the class in stateful_navigation_shell.dart? we can move the class to route.dart?

/// you need to specify both when customizing a page. For example:
///
Expand Down