Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go_router] Refactor internal classes and methods #2317

Merged
merged 38 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
370a279
Refactor internal classes and methods
johnpryan Jul 1, 2022
aaec44a
format
johnpryan Jul 12, 2022
61fbc2d
Sort imports
johnpryan Jul 12, 2022
632b012
Update changelog
johnpryan Jul 12, 2022
40e2c61
Address code review comments
johnpryan Jul 13, 2022
61da05d
remove routing library
johnpryan Jul 14, 2022
1c2577c
Move classes in go_router.dart into separate libraries
johnpryan Jul 14, 2022
db91f56
Move Configuration.validate() into constructor
johnpryan Jul 14, 2022
1eaf6c3
Remove comment
johnpryan Jul 14, 2022
ea01665
use continue in redirect loop
johnpryan Jul 14, 2022
d4c2ff9
Fix comments
johnpryan Jul 14, 2022
199c353
Sort imports
johnpryan Jul 14, 2022
b8a65af
Fix logging in configuration
johnpryan Jul 14, 2022
85fe41d
add visibleForTesting annotation
johnpryan Jul 14, 2022
ccb8097
Merge branch 'main' into refactor
johnpryan Jul 14, 2022
e0bb4f4
Updates from merge with main
johnpryan Jul 14, 2022
4c17bba
Format
johnpryan Jul 15, 2022
8449014
Add TODOs to make Router implementation classes private
johnpryan Jul 15, 2022
9b40f1e
Add copyright headers
johnpryan Jul 15, 2022
0e14a04
Fix tests
johnpryan Jul 15, 2022
73feaa8
Merge branch 'main' into refactor
johnpryan Jul 20, 2022
e3458e6
format
johnpryan Jul 20, 2022
13bc273
fix comment
johnpryan Jul 20, 2022
2a350ad
Update packages/go_router/lib/src/parser.dart
johnpryan Jul 21, 2022
fc82dbb
add whitespace
johnpryan Jul 21, 2022
86c8961
format
johnpryan Jul 21, 2022
7f8954c
Hide typedefs that weren't previously exported
johnpryan Jul 21, 2022
fdcf0ed
Delete empty file
johnpryan Jul 21, 2022
78e60a6
add missing import
johnpryan Jul 21, 2022
26b4c12
Specify version 4.1.2 in pubspec.yaml
johnpryan Jul 21, 2022
0c5436e
Update packages/go_router/lib/src/builder.dart
johnpryan Jul 21, 2022
348697b
Fix comment
johnpryan Jul 21, 2022
77f2244
Add isError and error getters to RouteMatchList
johnpryan Jul 21, 2022
820162d
Add issue links to TODO comments
johnpryan Jul 21, 2022
07f7ada
Add link to issue for TODO
johnpryan Jul 22, 2022
686d315
Merge branch 'main' into refactor
johnpryan Jul 22, 2022
5e282d3
Re-apply code from #2306 due to merge conflicts
johnpryan Jul 22, 2022
714e682
Add issue references
johnpryan Jul 22, 2022
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
30 changes: 30 additions & 0 deletions packages/go_router/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
4 changes: 4 additions & 0 deletions packages/go_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.1.2

- Refactors internal classes and methods

## 4.1.1

- Fixes a bug where calling namedLocation does not support case-insensitive way.
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/example/lib/books/src/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:flutter/widgets.dart';

/// A mock authentication service
/// A mock authentication service.
class BookstoreAuth extends ChangeNotifier {
bool _signedIn = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter/material.dart';

import 'package:go_router/go_router.dart';

/// The enum for scaffold tab
/// The enum for scaffold tab.
enum ScaffoldTab {
/// The books tab.
books,
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/example/lib/cupertino.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:go_router/go_router.dart';

void main() => runApp(App());

/// The main app
/// The main app.
class App extends StatelessWidget {
/// Creates an [App].
App({Key? key}) : super(key: key);
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/example/lib/error_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Page2Screen extends StatelessWidget {
);
}

/// The screen of the error page
/// The screen of the error page.
class ErrorScreen extends StatelessWidget {
/// Creates an [ErrorScreen].
const ErrorScreen(this.error, {Key? key}) : super(key: key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class _AppState extends State<App> {
return null;
},
// changes on the listenable will cause the router to refresh it's route
johnpryan marked this conversation as resolved.
Show resolved Hide resolved
// TODO(johnpryan): Deprecate GoRouterRefreshStream
johnpryan marked this conversation as resolved.
Show resolved Hide resolved
refreshListenable: GoRouterRefreshStream(loggedInState.stream),
);
super.initState();
Expand Down
4 changes: 2 additions & 2 deletions packages/go_router/example/lib/shared_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class SharedScaffold extends StatefulWidget {
Key? key,
}) : super(key: key);

/// The selected index
/// The selected index.
final int selectedIndex;

/// The body of the page.
Expand Down Expand Up @@ -173,7 +173,7 @@ class Page2View extends StatelessWidget {

/// The error scaffold.
class ErrorScaffold extends StatelessWidget {
/// Creates an [ErrorScaffold]
/// Creates an [ErrorScaffold].
const ErrorScaffold({
required this.body,
Key? key,
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/example/lib/transitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ExampleTransitionsScreen extends StatelessWidget {
/// The color of the container.
final Color color;

/// The transition kind
/// The transition kind.
final String kind;

@override
Expand Down
82 changes: 10 additions & 72 deletions packages/go_router/lib/go_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,15 @@
// found in the LICENSE file.

/// A declarative router for Flutter based on Navigation 2 supporting
/// deep linking, data-driven routes and more
/// deep linking, data-driven routes and more.
library go_router;

import 'package:flutter/widgets.dart';

import 'src/go_router.dart';

export 'src/custom_transition_page.dart';
export 'src/go_route.dart';
export 'src/go_router.dart';
export 'src/go_router_refresh_stream.dart';
export 'src/go_router_state.dart';
export 'src/inherited_go_router.dart';
export 'src/route_data.dart' show GoRouteData, TypedGoRoute;
export 'src/typedefs.dart' show GoRouterPageBuilder, GoRouterRedirect;
export 'src/url_path_strategy.dart';

/// Dart extension to add navigation function to a BuildContext object, e.g.
/// context.go('/');
// NOTE: adding this here instead of in /src to work-around a Dart analyzer bug
// and fix: https://github.com/csells/go_router/issues/116
extension GoRouterHelper on BuildContext {
/// Get a location from route name and parameters.
String namedLocation(
String name, {
Map<String, String> params = const <String, String>{},
Map<String, String> queryParams = const <String, String>{},
}) =>
GoRouter.of(this)
.namedLocation(name, params: params, queryParams: queryParams);

/// Navigate to a location.
void go(String location, {Object? extra}) =>
GoRouter.of(this).go(location, extra: extra);

/// Navigate to a named route.
void goNamed(
String name, {
Map<String, String> params = const <String, String>{},
Map<String, String> queryParams = const <String, String>{},
Object? extra,
}) =>
GoRouter.of(this).goNamed(
name,
params: params,
queryParams: queryParams,
extra: extra,
);

/// Push a location onto the page stack.
void push(String location, {Object? extra}) =>
GoRouter.of(this).push(location, extra: extra);

/// Navigate to a named route onto the page stack.
void pushNamed(
String name, {
Map<String, String> params = const <String, String>{},
Map<String, String> queryParams = const <String, String>{},
Object? extra,
}) =>
GoRouter.of(this).pushNamed(
name,
params: params,
queryParams: queryParams,
extra: extra,
);

/// Returns `true` if there is more than 1 page on the stack.
bool canPop() => GoRouter.of(this).canPop();

/// Pop the top page off the Navigator's page stack by calling
/// [Navigator.pop].
void pop() => GoRouter.of(this).pop();
}
export 'src/configuration.dart' show GoRouterState, GoRoute;
export 'src/misc/extensions.dart';
export 'src/misc/inherited_router.dart';
export 'src/misc/refresh_stream.dart';
export 'src/pages/custom_transition_page.dart';
export 'src/platform.dart' show UrlPathStrategy;
export 'src/router.dart';
export 'src/typed_routing.dart' show GoRouteData, TypedGoRoute;
export 'src/typedefs.dart';
Loading