1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-06 11:41:26 +00:00

Replace navigation_and_routing with a new sample (#832)

* move snippets into old_snippets directory

* add new navigation_and_routing sample

* add copyright headers

* Apply #827 to old_snippets/ directory and upgrade them to null safety

* Code review comments

- Move Guard class into parser.dart
- Move usage of guards from Delegate to RouteInformationParser
- Rename delegate to SimpleRouterDelegate

* clean up imports

* refactor settings screen, fix bug

* avoid conflicting paths /books/new and /books/1 - rename to book/1

* dispose fields in _BookstoreState class

* remove /books path

This was causing problems

* add comment

* Change BookstoreAuthScope and BookstoreAuthScope to InheritedNotifier

* fix warnings

* Make the initial route configurable, set to '/signin'

* Enable deep linking

https://flutter.dev/docs/development/ui/navigation/deep-linking

* use path URL strategy on the web.

* remove TODO, add comment
This commit is contained in:
John Ryan
2021-07-08 07:48:17 -07:00
committed by GitHub
parent 8573269c03
commit ae3c4e3c47
96 changed files with 3560 additions and 278 deletions

View File

@@ -1,47 +1,5 @@
# Navigation and Routing sample code
# bookstore
Sample code for [Learning Flutter's New Navigation and Routing System][article],
an article explaining the Router widget and its associated classes.
This sample shows how to set up a Router using a custom RouterDelegate and
RouteInformationParser.
## Samples
**Navigator samples**
* [navigator/anonymous_routes.dart](lib/navigator/anonymous_routes.dart) -
Shows how to use a Navigator to push and pop anonymous routes (e.g.
MaterialPageRoute)
* [navigator/named_routes.dart](lib/navigator/named_routes.dart) - Shows
how to use define named routes via the `routes` parameter on MaterialApp, and
navigate using Navigator.pushNamed
* [navigator/on_generate_route.dart](lib/navigator/on_generate_route.dart) -
Shows how to handle arbitrary named routes using the `onGenerateRoute`
callback defined in the `MaterialApp` constructor.
**Router samples**
* [router/pages.dart](lib/router/pages.dart) - Shows how to define a list of
[Page] objects on Navigator declaratively.
* [router/router.dart](lib/router/router.dart) - Full sample that shows a custom
RouteInformationParser and RouterDelegate parsing named routes and
declaratively building the stack of pages for the Navigator.
**Advanced**
* [router_advanced/nested_router.dart](lib/router_advanced/nested_router.dart) -
Shows two [RouterDelegate], one nested within the other. A
[BottomNavigationBar] can be used to select the route of the outer
RouterDelegate, and additional routes can be pushed onto the inner
RouterDelegate / Navigator.
* [router_advanced/transition_delegate.dart](lib/router_advanced/transition_delegate.dart)
Shows how a custom TransitionDelegate can be used to customize when
transition animations are shown.
## Running
Each file in this project is an entrypoint. To run, specify the filename of
the sample:
```bash
flutter run lib/router/router.dart
```
[article]: https://medium.com/flutter/learning-flutters-new-navigation-and-routing-system-7c9068155ade