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 lint treat super.key differently #3412

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

unused_element lint treat super.key differently #3412

xvrh opened this issue May 17, 2022 · 1 comment

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: dart-lang/sdk#49025

@xvrh xvrh closed this as completed May 17, 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