Skip to content

Commit 4549ba8

Browse files
authored
[go_router] Avoids using deprecated DartType.element2. (#2738)
1 parent b0d4601 commit 4549ba8

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

packages/go_router_builder/CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
## 1.0.15
2+
3+
* Avoids using deprecated DartType.element2.
4+
15
## 1.0.14
26

3-
* Bumps go_router version in example folder to v5.0.0
4-
* Bumps flutter version to 3.3.0
7+
* Bumps go_router version in example folder to v5.0.0.
8+
* Bumps flutter version to 3.3.0.
59

610
## 1.0.13
711

packages/go_router_builder/lib/src/route_config.dart

+13-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ class RouteConfig {
8888
}
8989

9090
// TODO(kevmoo): validate that this MUST be a subtype of `GoRouteData`
91-
final InterfaceElement classElement = typeParamType.element2;
91+
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
92+
// 5.2+ (when Flutter 3.4+ is on stable).
93+
// ignore: deprecated_member_use
94+
final InterfaceElement classElement = typeParamType.element;
9295

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

@@ -142,7 +145,7 @@ extension $_extensionName on $_className {
142145
void go(BuildContext context) => context.go(location, extra: this);
143146
144147
void push(BuildContext context) => context.push(location, extra: this);
145-
}
148+
}
146149
''';
147150

148151
/// Returns this [RouteConfig] and all child [RouteConfig] instances.
@@ -363,11 +366,17 @@ GoRouteData.\$route(
363366
String _enumMapConst(InterfaceType type) {
364367
assert(type.isEnum);
365368

366-
final String enumName = type.element2.name;
369+
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
370+
// 5.2+ (when Flutter 3.4+ is on stable).
371+
// ignore: deprecated_member_use
372+
final String enumName = type.element.name;
367373

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

370-
for (final FieldElement enumField in type.element2.fields
376+
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
377+
// 5.2+ (when Flutter 3.4+ is on stable).
378+
// ignore: deprecated_member_use
379+
for (final FieldElement enumField in type.element.fields
371380
.where((FieldElement element) => element.isEnumConstant)) {
372381
buffer.writeln(
373382
'$enumName.${enumField.name}: ${escapeDartString(enumField.name.kebab)},',

packages/go_router_builder/lib/src/type_helpers.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ String encodeField(PropertyAccessorElement element) {
7979
}
8080

8181
/// Gets the name of the `const` map generated to help encode [Enum] types.
82-
String enumMapName(InterfaceType type) => '_\$${type.element2.name}EnumMap';
82+
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
83+
// 5.2+ (when Flutter 3.4+ is on stable).
84+
// ignore: deprecated_member_use
85+
String enumMapName(InterfaceType type) => '_\$${type.element.name}EnumMap';
8386

8487
String _stateValueAccess(ParameterElement element) {
8588
if (element.isRequired) {

packages/go_router_builder/pubspec.yaml

+1-1
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: 1.0.14
5+
version: 1.0.15
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

0 commit comments

Comments
 (0)