Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ded3b07
adds name parameter to TypedGoRoute
dancamdev Apr 8, 2023
5f467ce
adds tests
dancamdev Apr 8, 2023
8592c5e
updates changelog and pubspec
dancamdev Apr 8, 2023
c5a5a40
uses local go_router
dancamdev Apr 8, 2023
2fad775
Merge remote-tracking branch 'upstream/main' into feature/add-name
dancamdev Apr 8, 2023
cfab739
Merge remote-tracking branch 'upstream/main' into feature/add-name
dancamdev Apr 13, 2023
637b37f
Update CHANGELOG.md
dancamdev Apr 13, 2023
94c5f3e
Update route_data.dart
dancamdev Apr 13, 2023
6ddd3c3
Update pubspec.yaml
dancamdev Apr 13, 2023
4b3c9e6
Merge branch 'main' into feature/add-name
dancamdev Apr 14, 2023
82ff212
Merge branch 'feature/add-name' of https://github.com/App-and-Up/pack…
dancamdev Apr 14, 2023
c4067c6
Merge branch 'main' into feature/add-name
dancamdev Apr 26, 2023
8ea4eda
Merge branch 'main' into feature/add-name
dancamdev Apr 27, 2023
c2df8aa
fix go_router version from local to remote
Michele-x98 Apr 27, 2023
49668c2
fix tests with return value from push method
Michele-x98 Apr 27, 2023
c034451
fix version
Michele-x98 Apr 27, 2023
ec70a3e
fixes build_runner error
dancamdev Apr 28, 2023
5f8390d
Merge remote-tracking branch 'upstream/main' into feature/add-name
dancamdev Apr 28, 2023
77ed12c
Merge branch 'main' into feature/add-name
Michele-x98 Apr 28, 2023
e0d5f4a
Merge branch 'main' into feature/add-name
dancamdev May 2, 2023
bb770a3
Merge remote-tracking branch 'upstream/main' into feature/add-name
dancamdev May 8, 2023
1ddc59c
adds NamedEscapeRoute test
dancamdev May 8, 2023
27da54a
fixes lint errors
dancamdev May 8, 2023
0e7df68
Merge branch 'main' into feature/add-name
dancamdev May 8, 2023
d3ad5dc
Merge branch 'main' into feature/add-name
dancamdev May 9, 2023
ad97e1f
Merge branch 'main' into feature/add-name
dancamdev May 10, 2023
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
Next Next commit
adds name parameter to TypedGoRoute
  • Loading branch information
dancamdev committed Apr 8, 2023
commit ded3b07dbe1c760cdbd3897b74b4310429ac629b
8 changes: 8 additions & 0 deletions packages/go_router/lib/src/route_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class TypedGoRoute<T extends GoRouteData> extends TypedRoute<T> {
/// Default const constructor
const TypedGoRoute({
required this.path,
this.name,
this.routes = const <TypedRoute<RouteData>>[],
this.parentNavigatorKey,
});
Expand All @@ -234,6 +235,13 @@ class TypedGoRoute<T extends GoRouteData> extends TypedRoute<T> {
///
final String path;

/// The name that corresponds to this route.
///
/// See [GoRoute.name].
///
///
final String? name;

/// Child route definitions.
///
/// See [RouteBase.routes].
Expand Down
14 changes: 14 additions & 0 deletions packages/go_router_builder/example/lib/all_types.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/go_router_builder/example/lib/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class App extends StatelessWidget {

@TypedGoRoute<HomeRoute>(
path: '/',
name: 'Home',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<FamilyRoute>(path: 'family/:familyId')
],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion packages/go_router_builder/lib/src/route_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class InfoIterable extends IterableBase<String> {
class RouteConfig {
RouteConfig._(
this._path,
this._name,
this._routeDataClass,
this._parent,
);
Expand Down Expand Up @@ -74,7 +75,10 @@ class RouteConfig {
);
}

final ConstantReader nameValue = reader.read('name');

final String path = pathValue.stringValue;
final String? name = nameValue.isNull ? null : nameValue.stringValue;

final InterfaceType type = reader.objectValue.type! as InterfaceType;
final DartType typeParamType = type.typeArguments.single;
Expand All @@ -93,7 +97,7 @@ class RouteConfig {
// ignore: deprecated_member_use
final InterfaceElement classElement = typeParamType.element;

final RouteConfig value = RouteConfig._(path, classElement, parent);
final RouteConfig value = RouteConfig._(path, name, classElement, parent);

value._children.addAll(reader.read('routes').listValue.map((DartObject e) =>
RouteConfig._fromAnnotation(ConstantReader(e), element, value)));
Expand All @@ -103,6 +107,7 @@ class RouteConfig {

final List<RouteConfig> _children = <RouteConfig>[];
final String _path;
final String? _name;
final InterfaceElement _routeDataClass;
final RouteConfig? _parent;

Expand Down Expand Up @@ -275,6 +280,7 @@ routes: [${_children.map((RouteConfig e) => '${e._routeDefinition()},').join()}]
return '''
GoRouteData.\$route(
path: ${escapeDartString(_path)},
name: ${_name == null ? null : escapeDartString(_name!)},
factory: $_extensionName._fromState,
$routesBit
)
Expand Down