Skip to content
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

unused_element false-positive when using super parameters on private classes #3434

Closed
mateusfccp opened this issue May 30, 2022 · 1 comment

Comments

@mateusfccp
Copy link

mateusfccp commented May 30, 2022

Describe the issue
Consider the following code:

class _MyWidget extends StatelessWidget {
  const _MyWidget({Key? key}) : super(key: key);

  // ...
}

This code won't trigger any info/warning.

However, if I use super parameters instead:

class _MyWidget extends StatelessWidget {
  const _MyWidget({super.key});

  // ...
}

The following info will be issued:
info: A value for optional parameter 'key' isn't ever given. (unused_element at [...] lib/...)

To Reproduce
Use the code above with Dart 2.17+ and unused_elements enabled.

Expected behavior
The linter should behave equally for both codes, as they are virtually the same. When using super parameters, however, the linter will incorrectly fire an info.

Additional context:
This issue, obviously, won't happen if the class is public.

Possible workaround:
A possible workaround is to provide a value, like ({super.key = null}). However, it does conflict with avoid_init_to_null.

@mateusfccp mateusfccp changed the title unused_elements false-positive when using super parameters on private classes unused_element false-positive when using super parameters on private classes May 30, 2022
@mateusfccp
Copy link
Author

Duplicate of dart-lang/sdk#49025.

@mateusfccp mateusfccp closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant