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

[analyzer] fix for use_key_in_widget_constructors should use super parameters when possible #48946

Closed
asashour opened this issue May 3, 2022 · 3 comments
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@asashour
Copy link
Contributor

asashour commented May 3, 2022

For a case like:

import 'package:flutter/material.dart';

class MyWidget extends StatefulWidget {
  @override
  State<MyWidget> createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  @override
  Widget build(context) => Container();
}

Adding 'key' to consturctor, would produce

const MyWidget({Key? key}) : super(key: key);

which is then offered to "convert to using super parameters".

It would be better to directly use super parameters on adding the 'key'.

Dart SDK version: 2.18.0-75.0.dev (dev) (Sun May 1 14:47:57 2022 -0700) on "windows_x64"

@lrhn lrhn added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 3, 2022
@pq pq added analyzer-quick-fix P1 A high priority bug; for example, a single project is unusable or has many test failures labels May 3, 2022
@pq
Copy link
Member

pq commented May 3, 2022

Tagging as P1 as use_key_in_widget_constructors is a flutter recommended lint.

@pq pq added the bug label May 3, 2022
@asashour
Copy link
Contributor Author

https://dart-review.googlesource.com/c/sdk/+/244242

@pq
Copy link
Member

pq commented May 10, 2022

Fantastic. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. 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

3 participants