Skip to content

Commit 61c98f1

Browse files
[go_router_builder] Ignore upcoming experimental_member_use warnings. (#10082)
In an upcoming Dart SDK change (https://dart-review.googlesource.com/c/sdk/+/450970), I intend to add logic to the analyzer for generating a warning if an API marked `@experimental` is used. This will allow experimental analyzer features to be developed without creating a risk of breaking changes downstream. Unfortunately, the `go_router_builder` package uses an old version of the analyzer in which some parts of the API were marked as `@experimental`, even though they were fully supported. So to avoid breaking trybots when the new warning rolls out, I need to add `// ignore` comments to ignore the upcoming warnings. In a future PR, I intend to bump the `go_router_builder` package's analyzer dependency to 8.2.0; in that analyzer version, the erroneous `@experimental` annotations have been removed. Unfortunately, that can't be done yet, since `go_router_builder` still needs to support versions of flutter that pin analyzer to an earlier version. (See #10079, which attempts to bump the analyzer dependency, but breaks trybots).
1 parent b783df0 commit 61c98f1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/go_router_builder/lib/src/route_config.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ abstract class RouteBaseConfig {
645645
}
646646

647647
// TODO(kevmoo): validate that this MUST be a subtype of `GoRouteData`
648+
// ignore: experimental_member_use
648649
final InterfaceElement2 classElement = typeParamType.element3;
649650

650651
final RouteBaseConfig value;
@@ -945,6 +946,7 @@ String _enumMapConst(InterfaceType type) {
945946

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

949+
// ignore: experimental_member_use
948950
for (final FieldElement2 enumField in type.element3.fields2.where(
949951
(FieldElement2 element) => element.isEnumConstant,
950952
)) {

packages/go_router_builder/lib/src/type_helpers.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ bool _isStringToStringFunction(
7272
/// Returns the custom codec for the annotation.
7373
String? _getCustomCodec(ElementAnnotation annotation, String name) {
7474
final ExecutableElement2? executableElement =
75+
// ignore: experimental_member_use
7576
annotation.computeConstantValue()?.getField(name)?.toFunctionValue2();
7677
if (_isStringToStringFunction(executableElement, name)) {
7778
return executableElement!.displayName;
@@ -188,10 +189,12 @@ T? getNodeDeclaration<T extends AstNode>(InterfaceElement2 element) {
188189
}
189190

190191
final ParsedLibraryResult parsedLibrary =
192+
// ignore: experimental_member_use
191193
session.getParsedLibraryByElement2(element.library2)
192194
as ParsedLibraryResult;
193195
final FragmentDeclarationResult? declaration = parsedLibrary
194-
.getFragmentDeclaration(element.firstFragment);
196+
// ignore: experimental_member_use
197+
.getFragmentDeclaration(element.firstFragment);
195198
final AstNode? node = declaration?.node;
196199

197200
return node is T ? node : null;
@@ -684,6 +687,7 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
684687

685688
final MethodElement2? toJsonMethod = type.lookUpMethod3(
686689
'toJson',
690+
// ignore: experimental_member_use
687691
type.element3.library2,
688692
);
689693
if (toJsonMethod == null ||
@@ -698,6 +702,7 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
698702
return _matchesType(type.typeArguments.first);
699703
}
700704

705+
// ignore: experimental_member_use
701706
final ConstructorElement2? fromJsonMethod = type.element3
702707
.getNamedConstructor2('fromJson');
703708

@@ -711,6 +716,7 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
711716
throw InvalidGenerationSourceError(
712717
'The parameter type '
713718
'`${type.getDisplayString(withNullability: false)}` not have a supported fromJson definition.',
719+
// ignore: experimental_member_use
714720
element: type.element3,
715721
);
716722
}
@@ -741,6 +747,7 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
741747

742748
bool _isNestedTemplate(InterfaceType type) {
743749
// check if has fromJson constructor
750+
// ignore: experimental_member_use
744751
final ConstructorElement2? fromJsonMethod = type.element3
745752
.getNamedConstructor2('fromJson');
746753
if (fromJsonMethod == null || !fromJsonMethod.isPublic) {
@@ -764,6 +771,7 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
764771
throw InvalidGenerationSourceError(
765772
'The parameter type '
766773
'`${type.getDisplayString(withNullability: false)}` not have a supported fromJson definition.',
774+
// ignore: experimental_member_use
767775
element: type.element3,
768776
);
769777
}
@@ -782,6 +790,7 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
782790
throw InvalidGenerationSourceError(
783791
'The parameter type '
784792
'`${type.getDisplayString(withNullability: false)}` not have a supported fromJson definition.',
793+
// ignore: experimental_member_use
785794
element: type.element3,
786795
);
787796
}

0 commit comments

Comments
 (0)