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_builder] Generate initialLocation with StatefulShellBranchConfig #4880

Merged
merged 11 commits into from
Sep 19, 2023
Merged
3 changes: 3 additions & 0 deletions packages/go_router_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.3.2
* Add initialLocation with StatefulShellBranchConfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Adds


## 2.3.1

* Adds pub topics to package metadata.
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 @@ -137,6 +137,7 @@ class StatefulShellBranchConfig extends RouteBaseConfig {
required super.routeDataClass,
required super.parent,
this.restorationScopeId,
this.initialLocation,
}) : super._();

/// The command for calling the navigator key getter from the ShellRouteData.
Expand All @@ -145,6 +146,9 @@ class StatefulShellBranchConfig extends RouteBaseConfig {
/// The restoration scope id.
final String? restorationScopeId;

/// The initial route.
final String? initialLocation;

@override
Iterable<String> classDeclarations() => <String>[];

Expand All @@ -153,7 +157,8 @@ class StatefulShellBranchConfig extends RouteBaseConfig {
@override
String get routeConstructorParameters =>
'${navigatorKey == null ? '' : 'navigatorKey: $navigatorKey,'}'
'${restorationScopeId == null ? '' : 'restorationScopeId: $restorationScopeId,'}';
'${restorationScopeId == null ? '' : 'restorationScopeId: $restorationScopeId,'}'
'${initialLocation == null ? '' : 'initialLocation: $initialLocation,'}';

@override
String get routeDataClassName => 'StatefulShellBranchData';
Expand Down Expand Up @@ -502,6 +507,10 @@ abstract class RouteBaseConfig {
classElement,
parameterName: r'$restorationScopeId',
),
initialLocation: _generateParameterGetterCode(
classElement,
parameterName: r'$initialLocation',
),
);
break;
case 'TypedGoRoute':
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.3.1
version: 2.3.2
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