Skip to content

use_key_in_widget_constructors triggers even though augmented class uses key #59444

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
Tracked by #59399
goderbauer opened this issue Apr 12, 2024 · 2 comments
Closed
Tracked by #59399
Assignees
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-new-language-feature linter-set-flutter P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@goderbauer
Copy link
Contributor

class Foo extends StatelessWidget { // 🔥 info: Constructors for public widgets should have a named 'key' parameter. (use_key_in_widget_constructors at [macros_playground] lib/main.dart:51)
  @override
  Widget build(BuildContext context) => const Placeholder();
}

augment class Foo {
  const Foo({Key? key}) : super(key: key);
}

The lint shouldn't complain here since Foo's constructor actually does have a key parameter.

@scheglov scheglov added linter-new-language-feature P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 13, 2024
@pq pq self-assigned this Apr 15, 2024
@pq
Copy link
Member

pq commented Apr 15, 2024

Good catch. Thanks for the report!

copybara-service bot referenced this issue Apr 16, 2024
Fixes: https://github.com/dart-lang/linter/issues/4936

Change-Id: Ib002878a1f7bf59db684f957d36eaf4e1a5b97bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362843
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
@pq
Copy link
Member

pq commented Apr 16, 2024

Fixed w/ 17fe19d

@pq pq closed this as completed Apr 16, 2024
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 20, 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. linter-new-language-feature linter-set-flutter P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

4 participants