|
1 | 1 | # Navigation and Routing sample code |
2 | 2 |
|
3 | 3 | Sample code for [Learning Flutter's New Navigation and Routing System][article], |
4 | | -an article explaining Navigator 2.0. |
| 4 | +an article explaining the Router widget and it's associated classes. |
5 | 5 |
|
6 | 6 | ## Samples |
7 | 7 |
|
8 | | -**Navigator 1.0 samples** |
| 8 | +**Navigator samples** |
9 | 9 |
|
10 | | -* [nav_1/anonymous_routes.dart](lib/nav_1/anonymous_routes.dart) - Shows how to |
11 | | - use a Navigator to push and pop anonymous routes (e.g. MaterialPageRoute) |
12 | | -* [nav_1/named_routes.dart](lib/nav_1/named_routes.dart) - Shows how to use |
13 | | - define named routes via the `routes` parameter on MaterialApp, and navigate |
14 | | - using Navigator.pushNamed |
15 | | -* [nav_1/on_generate_route.dart](lib/nav_1/on_generate_route.dart) - Shows how |
16 | | - to handle arbitrary named routes using the `onGenerateRoute` callback defined |
17 | | - in the `MaterialApp` constructor. |
| 10 | +* [navigator/anonymous_routes.dart](lib/navigator/anonymous_routes.dart) - |
| 11 | + Shows how to use a Navigator to push and pop anonymous routes (e.g. |
| 12 | + MaterialPageRoute) |
| 13 | +* [navigator/named_routes.dart](lib/navigator/named_routes.dart) - Shows |
| 14 | + how to use define named routes via the `routes` parameter on MaterialApp, and |
| 15 | + navigate using Navigator.pushNamed |
| 16 | +* [navigator/on_generate_route.dart](lib/navigator/on_generate_route.dart) - |
| 17 | + Shows how to handle arbitrary named routes using the `onGenerateRoute` |
| 18 | + callback defined in the `MaterialApp` constructor. |
18 | 19 |
|
19 | | -**Navigator 2.0 samples** |
| 20 | +**Router samples** |
20 | 21 |
|
21 | | -* [nav_2/pages.dart](lib/nav_2/pages.dart) - Shows how to define a list of |
| 22 | +* [router/pages.dart](lib/router/pages.dart) - Shows how to define a list of |
22 | 23 | [Page] objects on Navigator declaratively. |
23 | | -* [nav_2/router.dart](lib/nav_2/router.dart) - Full sample that shows a custom |
| 24 | +* [router/router.dart](lib/router/router.dart) - Full sample that shows a custom |
24 | 25 | RouteInformationParser and RouterDelegate parsing named routes and |
25 | 26 | declaratively building the stack of pages for the Navigator. |
26 | 27 |
|
27 | | - |
28 | 28 | **Advanced** |
29 | 29 |
|
30 | | -* [nav_2_advanced/nested_router.dart](lib/nav_2_advanced/nested_router.dart) - |
| 30 | +* [router_advanced/nested_router.dart](lib/router_advanced/nested_router.dart) - |
31 | 31 | Shows two [RouterDelegate], one nested within the other. A |
32 | 32 | [BottomNavigationBar] can be used to select the route of the outer |
33 | 33 | RouterDelegate, and additional routes can be pushed onto the inner |
34 | 34 | RouterDelegate / Navigator. |
35 | | -* [nav_2_advanced/transition_delegate.dart](lib/nav_2_advanced/transition_delegate.dart) |
| 35 | +* [router_advanced/transition_delegate.dart](lib/router_advanced/transition_delegate.dart) |
36 | 36 | Shows how a custom TransitionDelegate can be used to customized when |
37 | 37 | transition animations are shown. |
38 | 38 |
|
39 | | - |
40 | 39 | ## Running |
41 | 40 |
|
42 | 41 | Each file in this project is an entrypoint. To run, specify the filename of |
43 | 42 | the sample: |
44 | 43 |
|
45 | 44 | ```bash |
46 | | -flutter run lib/nav_2/router.dart |
| 45 | +flutter run lib/router/router.dart |
47 | 46 | ``` |
48 | | - |
49 | 47 | [article]: https://medium.com/flutter/learning-flutters-new-navigation-and-routing-system-7c9068155ade |
0 commit comments