|
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
5 | 5 | /// A declarative router for Flutter based on Navigation 2 supporting |
6 | | -/// deep linking, data-driven routes and more |
| 6 | +/// deep linking, data-driven routes and more. |
7 | 7 | library go_router; |
8 | 8 |
|
9 | | -import 'package:flutter/widgets.dart'; |
10 | | - |
11 | | -import 'src/go_router.dart'; |
12 | | - |
13 | | -export 'src/custom_transition_page.dart'; |
14 | | -export 'src/go_route.dart'; |
15 | | -export 'src/go_router.dart'; |
16 | | -export 'src/go_router_refresh_stream.dart'; |
17 | | -export 'src/go_router_state.dart'; |
18 | | -export 'src/inherited_go_router.dart'; |
19 | | -export 'src/route_data.dart' show GoRouteData, TypedGoRoute; |
| 9 | +export 'src/configuration.dart' show GoRouterState, GoRoute; |
| 10 | +export 'src/misc/extensions.dart'; |
| 11 | +export 'src/misc/inherited_router.dart'; |
| 12 | +export 'src/misc/refresh_stream.dart'; |
| 13 | +export 'src/pages/custom_transition_page.dart'; |
| 14 | +export 'src/platform.dart' show UrlPathStrategy; |
| 15 | +export 'src/router.dart'; |
| 16 | +export 'src/typed_routing.dart' show GoRouteData, TypedGoRoute; |
20 | 17 | export 'src/typedefs.dart' show GoRouterPageBuilder, GoRouterRedirect; |
21 | | -export 'src/url_path_strategy.dart'; |
22 | | - |
23 | | -/// Dart extension to add navigation function to a BuildContext object, e.g. |
24 | | -/// context.go('/'); |
25 | | -// NOTE: adding this here instead of in /src to work-around a Dart analyzer bug |
26 | | -// and fix: https://github.com/csells/go_router/issues/116 |
27 | | -extension GoRouterHelper on BuildContext { |
28 | | - /// Get a location from route name and parameters. |
29 | | - String namedLocation( |
30 | | - String name, { |
31 | | - Map<String, String> params = const <String, String>{}, |
32 | | - Map<String, String> queryParams = const <String, String>{}, |
33 | | - }) => |
34 | | - GoRouter.of(this) |
35 | | - .namedLocation(name, params: params, queryParams: queryParams); |
36 | | - |
37 | | - /// Navigate to a location. |
38 | | - void go(String location, {Object? extra}) => |
39 | | - GoRouter.of(this).go(location, extra: extra); |
40 | | - |
41 | | - /// Navigate to a named route. |
42 | | - void goNamed( |
43 | | - String name, { |
44 | | - Map<String, String> params = const <String, String>{}, |
45 | | - Map<String, String> queryParams = const <String, String>{}, |
46 | | - Object? extra, |
47 | | - }) => |
48 | | - GoRouter.of(this).goNamed( |
49 | | - name, |
50 | | - params: params, |
51 | | - queryParams: queryParams, |
52 | | - extra: extra, |
53 | | - ); |
54 | | - |
55 | | - /// Push a location onto the page stack. |
56 | | - void push(String location, {Object? extra}) => |
57 | | - GoRouter.of(this).push(location, extra: extra); |
58 | | - |
59 | | - /// Navigate to a named route onto the page stack. |
60 | | - void pushNamed( |
61 | | - String name, { |
62 | | - Map<String, String> params = const <String, String>{}, |
63 | | - Map<String, String> queryParams = const <String, String>{}, |
64 | | - Object? extra, |
65 | | - }) => |
66 | | - GoRouter.of(this).pushNamed( |
67 | | - name, |
68 | | - params: params, |
69 | | - queryParams: queryParams, |
70 | | - extra: extra, |
71 | | - ); |
72 | | - |
73 | | - /// Replaces the top-most page of the page stack with the given URL location |
74 | | - /// w/ optional query parameters, e.g. `/family/f2/person/p1?color=blue`. |
75 | | - /// |
76 | | - /// See also: |
77 | | - /// * [go] which navigates to the location. |
78 | | - /// * [push] which pushes the location onto the page stack. |
79 | | - void replace(String location, {Object? extra}) => |
80 | | - GoRouter.of(this).replace(location, extra: extra); |
81 | | - |
82 | | - /// Replaces the top-most page of the page stack with the named route w/ |
83 | | - /// optional parameters, e.g. `name='person', params={'fid': 'f2', 'pid': |
84 | | - /// 'p1'}`. |
85 | | - /// |
86 | | - /// See also: |
87 | | - /// * [goNamed] which navigates a named route. |
88 | | - /// * [pushNamed] which pushes a named route onto the page stack. |
89 | | - void replaceNamed( |
90 | | - String name, { |
91 | | - Map<String, String> params = const <String, String>{}, |
92 | | - Map<String, String> queryParams = const <String, String>{}, |
93 | | - Object? extra, |
94 | | - }) => |
95 | | - GoRouter.of(this).replaceNamed( |
96 | | - name, |
97 | | - params: params, |
98 | | - queryParams: queryParams, |
99 | | - extra: extra, |
100 | | - ); |
101 | | - |
102 | | - /// Returns `true` if there is more than 1 page on the stack. |
103 | | - bool canPop() => GoRouter.of(this).canPop(); |
104 | | - |
105 | | - /// Pop the top page off the Navigator's page stack by calling |
106 | | - /// [Navigator.pop]. |
107 | | - void pop() => GoRouter.of(this).pop(); |
108 | | -} |
0 commit comments