mirror of
https://github.com/flutter/packages.git
synced 2025-07-02 08:34:31 +08:00
[go_router] Exposes package-level privates (#4380)
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 9.0.2
|
||||
|
||||
- Exposes package-level privates.
|
||||
|
||||
## 9.0.1
|
||||
|
||||
- Allows redirect only GoRoute to be part of RouteMatchList.
|
||||
@ -5,8 +9,7 @@
|
||||
## 9.0.0
|
||||
|
||||
- **BREAKING CHANGE**:
|
||||
- Removes GoRouter.location and GoRouter.canPop. Use GoRouterState.of().location and
|
||||
Navigator.of().canPop instead.
|
||||
- Removes GoRouter.location. Use GoRouterState.of().location instead.
|
||||
- GoRouter does not `extends` ChangeNotifier.
|
||||
- [Migration guide](https://flutter.dev/go/go-router-v9-breaking-changes)
|
||||
- Reduces excessive rebuilds due to inherited look up.
|
||||
|
@ -6,35 +6,17 @@
|
||||
/// deep linking, data-driven routes and more.
|
||||
library go_router;
|
||||
|
||||
export 'src/configuration.dart'
|
||||
show
|
||||
GoRoute,
|
||||
GoRouterState,
|
||||
RouteBase,
|
||||
ShellRoute,
|
||||
ShellNavigationContainerBuilder,
|
||||
StatefulNavigationShell,
|
||||
StatefulNavigationShellState,
|
||||
StatefulShellBranch,
|
||||
StatefulShellRoute;
|
||||
export 'src/builder.dart';
|
||||
export 'src/configuration.dart';
|
||||
export 'src/delegate.dart';
|
||||
export 'src/information_provider.dart';
|
||||
export 'src/match.dart' hide RouteMatchListCodec;
|
||||
export 'src/misc/errors.dart';
|
||||
export 'src/misc/extensions.dart';
|
||||
export 'src/misc/inherited_router.dart';
|
||||
export 'src/pages/custom_transition_page.dart';
|
||||
export 'src/route_data.dart'
|
||||
show
|
||||
RouteData,
|
||||
GoRouteData,
|
||||
ShellRouteData,
|
||||
TypedRoute,
|
||||
TypedGoRoute,
|
||||
TypedShellRoute;
|
||||
export 'src/parser.dart';
|
||||
export 'src/route.dart';
|
||||
export 'src/route_data.dart' hide NoOpPage;
|
||||
export 'src/router.dart';
|
||||
export 'src/typedefs.dart'
|
||||
show
|
||||
GoRouterPageBuilder,
|
||||
GoRouterRedirect,
|
||||
GoRouterWidgetBuilder,
|
||||
ShellRouteBuilder,
|
||||
ShellRoutePageBuilder,
|
||||
StatefulShellRouteBuilder,
|
||||
StatefulShellRoutePageBuilder;
|
||||
export 'src/state.dart' hide GoRouterStateRegistry, GoRouterStateRegistryScope;
|
||||
|
@ -5,16 +5,23 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../go_router.dart';
|
||||
import 'configuration.dart';
|
||||
import 'logging.dart';
|
||||
import 'match.dart';
|
||||
import 'misc/error_screen.dart';
|
||||
import 'misc/errors.dart';
|
||||
import 'pages/cupertino.dart';
|
||||
import 'pages/custom_transition_page.dart';
|
||||
import 'pages/material.dart';
|
||||
import 'route.dart';
|
||||
import 'route_data.dart';
|
||||
import 'typedefs.dart';
|
||||
import 'state.dart';
|
||||
|
||||
/// Signature of a go router builder function with navigator.
|
||||
typedef GoRouterBuilderWithNav = Widget Function(
|
||||
BuildContext context,
|
||||
Widget child,
|
||||
);
|
||||
|
||||
/// Signature for a function that takes in a `route` to be popped with
|
||||
/// the `result` and returns a boolean decision on whether the pop
|
||||
|
@ -6,14 +6,16 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'configuration.dart';
|
||||
import 'logging.dart';
|
||||
import 'match.dart';
|
||||
import 'misc/errors.dart';
|
||||
import 'path_utils.dart';
|
||||
import 'typedefs.dart';
|
||||
export 'route.dart';
|
||||
export 'state.dart';
|
||||
import 'route.dart';
|
||||
import 'state.dart';
|
||||
|
||||
/// The signature of the redirect callback.
|
||||
typedef GoRouterRedirect = FutureOr<String?> Function(
|
||||
BuildContext context, GoRouterState state);
|
||||
|
||||
/// The route configuration for GoRouter configured by the app.
|
||||
class RouteConfiguration {
|
||||
|
@ -7,12 +7,11 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../go_router.dart';
|
||||
import 'builder.dart';
|
||||
import 'configuration.dart';
|
||||
import 'match.dart';
|
||||
import 'misc/errors.dart';
|
||||
import 'typedefs.dart';
|
||||
import 'route.dart';
|
||||
|
||||
/// GoRouter implementation of [RouterDelegate].
|
||||
class GoRouterDelegate extends RouterDelegate<RouteMatchList>
|
||||
@ -26,7 +25,6 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
|
||||
required GoRouterWidgetBuilder? errorBuilder,
|
||||
required List<NavigatorObserver> observers,
|
||||
required this.routerNeglect,
|
||||
required this.onException,
|
||||
String? restorationScopeId,
|
||||
}) : _configuration = configuration {
|
||||
builder = RouteBuilder(
|
||||
@ -47,13 +45,6 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
|
||||
/// Set to true to disable creating history entries on the web.
|
||||
final bool routerNeglect;
|
||||
|
||||
/// The exception handler that is called when parser can't handle the incoming
|
||||
/// uri.
|
||||
///
|
||||
/// If this is null, the exception is handled in the
|
||||
/// [RouteBuilder.errorPageBuilder] or [RouteBuilder.errorBuilder].
|
||||
final GoExceptionHandler? onException;
|
||||
|
||||
final RouteConfiguration _configuration;
|
||||
|
||||
_NavigatorStateIterator _createNavigatorStateIterator() =>
|
||||
|
@ -8,10 +8,12 @@ import 'dart:convert';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'configuration.dart';
|
||||
import 'misc/errors.dart';
|
||||
import 'path_utils.dart';
|
||||
import 'route.dart';
|
||||
|
||||
/// An matched result by matching a [RouteBase] against a location.
|
||||
///
|
||||
@ -355,6 +357,7 @@ class RouteMatchList {
|
||||
/// suitable for using with [StandardMessageCodec].
|
||||
///
|
||||
/// The primary use of this class is for state restoration.
|
||||
@internal
|
||||
class RouteMatchListCodec extends Codec<RouteMatchList, Map<Object?, Object?>> {
|
||||
/// Creates a new [RouteMatchListCodec] object.
|
||||
RouteMatchListCodec(RouteConfiguration configuration)
|
||||
|
@ -8,11 +8,12 @@ import 'dart:math';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../go_router.dart';
|
||||
import 'configuration.dart';
|
||||
import 'information_provider.dart';
|
||||
import 'logging.dart';
|
||||
import 'match.dart';
|
||||
import 'route.dart';
|
||||
import 'router.dart';
|
||||
|
||||
/// The function signature of [GoRouteInformationParser.onParserException].
|
||||
///
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../go_router.dart';
|
||||
import 'route.dart';
|
||||
|
||||
final RegExp _parameterRegExp = RegExp(r':(\w+)(\((?:\\.|[^\\()])+\))?');
|
||||
|
||||
|
@ -7,11 +7,55 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../go_router.dart';
|
||||
import 'configuration.dart';
|
||||
import 'match.dart';
|
||||
import 'path_utils.dart';
|
||||
import 'typedefs.dart';
|
||||
import 'router.dart';
|
||||
import 'state.dart';
|
||||
|
||||
/// The page builder for [GoRoute].
|
||||
typedef GoRouterPageBuilder = Page<dynamic> Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
);
|
||||
|
||||
/// The widget builder for [GoRoute].
|
||||
typedef GoRouterWidgetBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
);
|
||||
|
||||
/// The widget builder for [ShellRoute].
|
||||
typedef ShellRouteBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
Widget child,
|
||||
);
|
||||
|
||||
/// The page builder for [ShellRoute].
|
||||
typedef ShellRoutePageBuilder = Page<dynamic> Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
Widget child,
|
||||
);
|
||||
|
||||
/// The widget builder for [StatefulShellRoute].
|
||||
typedef StatefulShellRouteBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
StatefulNavigationShell navigationShell,
|
||||
);
|
||||
|
||||
/// The page builder for [StatefulShellRoute].
|
||||
typedef StatefulShellRoutePageBuilder = Page<dynamic> Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
StatefulNavigationShell navigationShell,
|
||||
);
|
||||
|
||||
/// Signature for functions used to build Navigators
|
||||
typedef NavigatorBuilder = Widget Function(
|
||||
List<NavigatorObserver>? observers, String? restorationScopeId);
|
||||
|
||||
/// The base class for [GoRoute] and [ShellRoute].
|
||||
///
|
||||
|
@ -11,13 +11,14 @@ import 'package:meta/meta_meta.dart';
|
||||
import 'route.dart';
|
||||
import 'state.dart';
|
||||
|
||||
/// A superclass for each route data
|
||||
/// Baseclass for supporting
|
||||
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
|
||||
abstract class RouteData {
|
||||
/// Default const constructor
|
||||
/// Allows subclasses to have `const` constructors.
|
||||
const RouteData();
|
||||
}
|
||||
|
||||
/// Baseclass for supporting
|
||||
/// A class to represent a [GoRoute] in
|
||||
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
|
||||
///
|
||||
/// Subclasses must override one of [build], [buildPage], or
|
||||
@ -123,10 +124,12 @@ abstract class GoRouteData extends RouteData {
|
||||
);
|
||||
}
|
||||
|
||||
/// Base class for supporting
|
||||
/// [nested navigation](https://pub.dev/packages/go_router#nested-navigation)
|
||||
/// A class to represent a [ShellRoute] in
|
||||
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
|
||||
abstract class ShellRouteData extends RouteData {
|
||||
/// Default const constructor
|
||||
/// Allows subclasses to have `const` constructors.
|
||||
///
|
||||
/// [ShellRouteData] is abstract and cannot be instantiated directly.
|
||||
const ShellRouteData();
|
||||
|
||||
/// [pageBuilder] is used to build the page
|
||||
|
@ -12,7 +12,8 @@ import 'match.dart';
|
||||
import 'misc/errors.dart';
|
||||
import 'misc/inherited_router.dart';
|
||||
import 'parser.dart';
|
||||
import 'typedefs.dart';
|
||||
import 'route.dart';
|
||||
import 'state.dart';
|
||||
|
||||
/// The function signature of [GoRouter.onException].
|
||||
///
|
||||
@ -139,7 +140,6 @@ class GoRouter implements RouterConfig<RouteMatchList> {
|
||||
|
||||
routerDelegate = GoRouterDelegate(
|
||||
configuration: configuration,
|
||||
onException: onException,
|
||||
errorPageBuilder: errorPageBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
routerNeglect: routerNeglect,
|
||||
|
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'configuration.dart';
|
||||
import 'misc/errors.dart';
|
||||
@ -181,6 +182,7 @@ class GoRouterState {
|
||||
///
|
||||
/// Should not be used directly, consider using [GoRouterState.of] to access
|
||||
/// [GoRouterState] from the context.
|
||||
@internal
|
||||
class GoRouterStateRegistryScope
|
||||
extends InheritedNotifier<GoRouterStateRegistry> {
|
||||
/// Creates a GoRouterStateRegistryScope.
|
||||
@ -195,6 +197,7 @@ class GoRouterStateRegistryScope
|
||||
///
|
||||
/// Should not be used directly, consider using [GoRouterState.of] to access
|
||||
/// [GoRouterState] from the context.
|
||||
@internal
|
||||
class GoRouterStateRegistry extends ChangeNotifier {
|
||||
/// creates a [GoRouterStateRegistry].
|
||||
GoRouterStateRegistry();
|
||||
|
@ -1,63 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async' show FutureOr;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'configuration.dart';
|
||||
|
||||
/// The widget builder for [GoRoute].
|
||||
typedef GoRouterWidgetBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
);
|
||||
|
||||
/// The page builder for [GoRoute].
|
||||
typedef GoRouterPageBuilder = Page<dynamic> Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
);
|
||||
|
||||
/// The widget builder for [ShellRoute].
|
||||
typedef ShellRouteBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
Widget child,
|
||||
);
|
||||
|
||||
/// The page builder for [ShellRoute].
|
||||
typedef ShellRoutePageBuilder = Page<dynamic> Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
Widget child,
|
||||
);
|
||||
|
||||
/// The widget builder for [StatefulShellRoute].
|
||||
typedef StatefulShellRouteBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
StatefulNavigationShell navigationShell,
|
||||
);
|
||||
|
||||
/// The page builder for [StatefulShellRoute].
|
||||
typedef StatefulShellRoutePageBuilder = Page<dynamic> Function(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
StatefulNavigationShell navigationShell,
|
||||
);
|
||||
|
||||
/// Signature of a go router builder function with navigator.
|
||||
typedef GoRouterBuilderWithNav = Widget Function(
|
||||
BuildContext context,
|
||||
Widget child,
|
||||
);
|
||||
|
||||
/// The signature of the redirect callback.
|
||||
typedef GoRouterRedirect = FutureOr<String?> Function(
|
||||
BuildContext context, GoRouterState state);
|
||||
|
||||
/// Signature for functions used to build Navigators
|
||||
typedef NavigatorBuilder = Widget Function(
|
||||
List<NavigatorObserver>? observers, String? restorationScopeId);
|
@ -1,7 +1,7 @@
|
||||
name: go_router
|
||||
description: A declarative router for Flutter based on Navigation 2 supporting
|
||||
deep linking, data-driven routes and more
|
||||
version: 9.0.1
|
||||
version: 9.0.2
|
||||
repository: https://github.com/flutter/packages/tree/main/packages/go_router
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22
|
||||
|
||||
|
@ -4,10 +4,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/src/builder.dart';
|
||||
import 'package:go_router/src/configuration.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
import 'package:go_router/src/router.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'test_helpers.dart';
|
||||
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/src/configuration.dart';
|
||||
import 'package:go_router/src/misc/errors.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'test_helpers.dart';
|
||||
|
||||
|
@ -5,9 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
import 'package:go_router/src/misc/error_screen.dart';
|
||||
import 'package:go_router/src/misc/errors.dart';
|
||||
|
||||
import 'test_helpers.dart';
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
|
||||
void main() {
|
||||
group('replaceNamed', () {
|
||||
|
@ -5,7 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/configuration.dart';
|
||||
import 'package:go_router/src/state.dart';
|
||||
|
||||
import 'test_helpers.dart';
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/src/information_provider.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
const String initialRoute = '/';
|
||||
const String newRoute = '/new';
|
||||
|
@ -5,7 +5,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
|
||||
void main() {
|
||||
group('RouteMatch', () {
|
||||
|
@ -6,9 +6,8 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/src/configuration.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
import 'package:go_router/src/router.dart';
|
||||
|
||||
import 'test_helpers.dart';
|
||||
|
||||
|
@ -5,10 +5,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/configuration.dart';
|
||||
import 'package:go_router/src/information_provider.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
import 'package:go_router/src/parser.dart';
|
||||
|
||||
RouteInformation createRouteInformation(String location, [Object? extra]) {
|
||||
return RouteInformation(
|
||||
|
@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:go_router/src/match.dart';
|
||||
|
||||
Future<GoRouter> createGoRouter(WidgetTester tester) async {
|
||||
final GoRouter goRouter = GoRouter(
|
||||
|
Reference in New Issue
Block a user