Skip to content

[go_router] Avoids using deprecated DartType.element2. #2738

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

Merged
merged 5 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ task:
- name: downgraded_analyze
depends_on: analyze
analyze_script:
- ./script/tool_runner.sh analyze --downgrade --custom-analysis=script/configs/custom_analysis.yaml
# TODO(chunhtai): Includes go_router_builder once downgraded_analyze picks up the latest
# change https://github.com/flutter/flutter/issues/114106.
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g Oct 26, 2022

Choose a reason for hiding this comment

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

I don't understand what this comment means; downgraded analyze uses the lowest version your pubspec allows. The only way to change what version it gets is to change your pubspec, so I don't see what the TODO is here that can't just be done right now instead (or if it can't, why not, and what the plan is for changing that).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah you are right let me try to bump up the analyzer version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, bump the pubspec yaml version

- ./script/tool_runner.sh analyze --downgrade --custom-analysis=script/configs/custom_analysis.yaml --exclude=go_router_builder
- name: readme_excerpts
env:
CIRRUS_CLONE_SUBMODULES: true
Expand Down
8 changes: 6 additions & 2 deletions packages/go_router_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## 1.0.15

* Avoids using deprecated DartType.element2.

## 1.0.14

* Bumps go_router version in example folder to v5.0.0
* Bumps flutter version to 3.3.0
* Bumps go_router version in example folder to v5.0.0.
* Bumps flutter version to 3.3.0.

## 1.0.13

Expand Down
6 changes: 3 additions & 3 deletions packages/go_router_builder/lib/src/route_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class RouteConfig {
}

// TODO(kevmoo): validate that this MUST be a subtype of `GoRouteData`
final InterfaceElement classElement = typeParamType.element2;
final InterfaceElement classElement = typeParamType.element;

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

Expand Down Expand Up @@ -363,11 +363,11 @@ GoRouteData.\$route(
String _enumMapConst(InterfaceType type) {
assert(type.isEnum);

final String enumName = type.element2.name;
final String enumName = type.element.name;

final StringBuffer buffer = StringBuffer('const ${enumMapName(type)} = {');

for (final FieldElement enumField in type.element2.fields
for (final FieldElement enumField in type.element.fields
.where((FieldElement element) => element.isEnumConstant)) {
buffer.writeln(
'$enumName.${enumField.name}: ${escapeDartString(enumField.name.kebab)},',
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router_builder/lib/src/type_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ String encodeField(PropertyAccessorElement element) {
}

/// Gets the name of the `const` map generated to help encode [Enum] types.
String enumMapName(InterfaceType type) => '_\$${type.element2.name}EnumMap';
String enumMapName(InterfaceType type) => '_\$${type.element.name}EnumMap';

String _stateValueAccess(ParameterElement element) {
if (element.isRequired) {
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: 1.0.14
version: 1.0.15
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