Skip to content
Merged
Changes from all 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
2 changes: 2 additions & 0 deletions packages/go_router_builder/lib/src/type_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,11 @@ class _TypeHelperJson extends _TypeHelperWithHelper {
}

final FunctionType functionType = secondParam.type as FunctionType;
// ignore: experimental_member_use
if (functionType.formalParameters.length != 1 ||
functionType.returnType.getDisplayString() !=
type.element.typeParameters.first.displayName ||
// ignore: experimental_member_use
functionType.formalParameters[0].type.getDisplayString() != 'Object?') {
Comment on lines +798 to 803

Choose a reason for hiding this comment

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

medium

You've added ignore comments for formalParameters, but functionType.returnType on line 800 is also an experimental member and is missing an ignore comment. This could lead to analyzer warnings.

To make this cleaner and ensure all experimental usages are covered, consider extracting the properties that use experimental APIs into local variables. This localizes the suppression comments and improves the readability of the if condition.

Suggested change
// ignore: experimental_member_use
if (functionType.formalParameters.length != 1 ||
functionType.returnType.getDisplayString() !=
type.element.typeParameters.first.displayName ||
// ignore: experimental_member_use
functionType.formalParameters[0].type.getDisplayString() != 'Object?') {
// ignore: experimental_member_use
final List<ParameterElement> formalParameters = functionType.formalParameters;
// ignore: experimental_member_use
final DartType returnType = functionType.returnType;
if (formalParameters.length != 1 ||
returnType.getDisplayString() !=
type.element.typeParameters.first.displayName ||
formalParameters[0].type.getDisplayString() != 'Object?') {

Copy link
Contributor

Choose a reason for hiding this comment

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

You've added ignore comments for formalParameters, but functionType.returnType on line 800 is also an experimental member and is missing an ignore comment. This could lead to analyzer warnings.

Hopefully everyone takes AI code reviews with a grain of salt, but just in case someone is thinking of applying this suggestion: I see no evidence to back up this claim. AFAICT, FunctionType.returnType is not an experimental member, and I don't believe it ever has been.

throw InvalidGenerationSourceError(
'The parameter type '
Expand Down