Skip to content

unused_element lint treat super.key differently #58740

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

Closed
xvrh opened this issue May 17, 2022 · 1 comment
Closed

unused_element lint treat super.key differently #58740

xvrh opened this issue May 17, 2022 · 1 comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.

Comments

@xvrh
Copy link
Contributor

xvrh commented May 17, 2022

When I write a Widget in Flutter, recommended practice is to add key parameter.
IDE template is generating code like this:

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

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

This code doesn't produce any lint.

Now I update my code/templates to conform to use_super_parameters feature:

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

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Now, the linter reports an unused_element lint (because my widget is private):
info: A value for optional parameter 'key' isn't ever given. (unused_element at [x] example.dart:74)

It seems the linter treat the old and new super differently to determine if a parameter is used or not.

@xvrh
Copy link
Contributor Author

xvrh commented May 17, 2022

I close this issue as it was already raised here: #49025

@xvrh xvrh closed this as completed May 17, 2022
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

2 participants