Skip to content

Commit ed67a29

Browse files
authored
[go_router_builder] Fix unnecessary whitespace in generated RelativeGoRouteData (#9875)
As can be seen in the [go_router_builder relative route example](https://github.com/flutter/packages/blob/main/packages/go_router_builder/example/lib/go_relative.g.dart), there is unnecessary whitespace in the generated output of `RelativeGoRouteData`. This PR fixes the whitespace issue and adjusts `run_tests.dart` to catch similar issues/regressions in the future. Closes flutter/flutter#174339. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent f787951 commit ed67a29

File tree

7 files changed

+12
-18
lines changed

7 files changed

+12
-18
lines changed

packages/go_router_builder/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.0.1
2+
3+
- Fixes unnecessary whitespace in generated `RelativeGoRouteData`.
4+
15
## 4.0.0
26

37
- Make Route mixins public.

packages/go_router_builder/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
dev_dependencies:
1414
# ...along with your other dev-dependencies
1515
build_runner: ^2.6.0
16-
go_router_builder: ^3.3.0
16+
go_router_builder: ^4.0.1
1717
```
1818
1919
### Source code

packages/go_router_builder/example/lib/go_relative.g.dart

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/example/lib/readme_excerpts.g.dart

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/go_router_builder/lib/src/route_config.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,10 @@ mixin $_mixinName on $routeDataClassName {
572572
}
573573

574574
@override
575-
String get routeConstructorParameters => '''
576-
path: ${escapeDartString(path)},
577-
${caseSensitive ? '' : 'caseSensitive: $caseSensitive,'}
578-
${parentNavigatorKey == null ? '' : 'parentNavigatorKey: $parentNavigatorKey,'}
579-
''';
575+
String get routeConstructorParameters =>
576+
'path: ${escapeDartString(path)},'
577+
'${caseSensitive ? '' : 'caseSensitive: $caseSensitive,'}'
578+
'${parentNavigatorKey == null ? '' : 'parentNavigatorKey: $parentNavigatorKey,'}';
580579

581580
@override
582581
String get routeDataClassName => 'RelativeGoRouteData';

packages/go_router_builder/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: go_router_builder
22
description: >-
33
A builder that supports generated strongly-typed route helpers for
44
package:go_router
5-
version: 4.0.0
5+
version: 4.0.1
66
repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder
77
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22
88

packages/go_router_builder/tool/run_tests.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ Future<void> main() async {
6161
}
6262

6363
// Apply consistent formatting to both generated and expected code for comparison.
64-
final String generated = formatter.format(
65-
results.join().replaceAll('\n', ''),
66-
);
67-
final String expected = formatter.format(
68-
expectResult.replaceAll('\n', ''),
69-
);
64+
final String generated = formatter.format(results.join('\n\n').trim());
65+
final String expected = formatter.format(expectResult.trim());
7066
expect(generated, equals(expected));
7167
}, timeout: const Timeout(Duration(seconds: 100)));
7268
}

0 commit comments

Comments
 (0)