Skip to content
Merged
Next Next commit
feat: add initialLocation to StatefulShellBranchConfig
  • Loading branch information
GeekAbdelouahed committed Sep 10, 2023
commit 80e5cf1bf564f487eb73fb12fd732cff959faeef
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