Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion packages/go_router_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## NEXT
## 2.5.0

* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
* Updates dependencies to require `analyzer` 5.2.0 or later.
* Adds `restorationScopeId` to `ShellRouteData`.

## 2.4.1

Expand Down
11 changes: 10 additions & 1 deletion packages/go_router_builder/lib/src/route_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ShellRouteConfig extends RouteBaseConfig {
required super.routeDataClass,
required this.observers,
required super.parent,
required this.restorationScopeId,
}) : super._();

/// The command for calling the navigator key getter from the ShellRouteData.
Expand All @@ -53,6 +54,9 @@ class ShellRouteConfig extends RouteBaseConfig {
/// The navigator observers.
final String? observers;

/// The restoration scope id.
final String? restorationScopeId;

@override
Iterable<String> classDeclarations() {
if (routeDataClass.unnamedConstructor == null) {
Expand All @@ -77,7 +81,8 @@ class ShellRouteConfig extends RouteBaseConfig {
String get routeConstructorParameters =>
'${navigatorKey == null ? '' : 'navigatorKey: $navigatorKey,'}'
'${parentNavigatorKey == null ? '' : 'parentNavigatorKey: $parentNavigatorKey,'}'
'${observers == null ? '' : 'observers: $observers,'}';
'${observers == null ? '' : 'observers: $observers,'}'
'${restorationScopeId == null ? '' : 'restorationScopeId: $restorationScopeId,'}';

@override
String get factorConstructorParameters =>
Expand Down Expand Up @@ -478,6 +483,10 @@ abstract class RouteBaseConfig {
classElement,
parameterName: r'$observers',
),
restorationScopeId: _generateParameterGetterCode(
classElement,
parameterName: r'$restorationScopeId',
),
);
case 'TypedStatefulShellRoute':
value = StatefulShellRouteConfig._(
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router_builder/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: go_router_builder
description: >-
A builder that supports generated strongly-typed route helpers for
package:go_router
version: 2.4.1
version: 2.5.0
repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ class ShellRouteNoConstConstructor extends ShellRouteData {}
class ShellRouteWithConstConstructor extends ShellRouteData {
const ShellRouteWithConstConstructor();
}

@TypedShellRoute<ShellRouteWithRestorationScopeId>(
routes: <TypedRoute<RouteData>>[],
)
class ShellRouteWithRestorationScopeId extends ShellRouteData {
const ShellRouteWithRestorationScopeId();

static const String $restorationScopeId = 'shellRouteWithRestorationScopeId';
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ extension $ShellRouteWithConstConstructorExtension
static ShellRouteWithConstConstructor _fromState(GoRouterState state) =>
const ShellRouteWithConstConstructor();
}

RouteBase get $shellRouteWithRestorationScopeId => ShellRouteData.$route(
restorationScopeId: ShellRouteWithRestorationScopeId.$restorationScopeId,
factory: $ShellRouteWithRestorationScopeIdExtension._fromState,
);

extension $ShellRouteWithRestorationScopeIdExtension
on ShellRouteWithRestorationScopeId {
static ShellRouteWithRestorationScopeId _fromState(GoRouterState state) =>
const ShellRouteWithRestorationScopeId();
}