flutter / flutter/flutter-intellij

Missing 'add key parameter' refactoring on const constructors

Open
#5,893 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2k
Forks
356
Avg merge
1d 11h
Merged PRs (30d)
27

Description

## Steps to Reproduce

The Dart Analyzer always tells me, that I should add the Key parameter to the widget constructor. There is a quick fix refactoring (Project quick fix, Alt+Enter/Option+Enter), for this, that only shows up, if the constructor isn't const.

`const SomeWidget({required String this.someParam});`
Refactorings:
* Convert to block body

`SomeWidget({required String this.someParam});`
Refactorings:
* Add 'const' modifier
* Add 'key' to constructors
* Convert to block body

It would be helpful to have the add-key-refactoring also for const constructors. On the other hand, the 'Convert to block body' refactoring makes no sense for const constructors, because const constructors must have no body.

## Version info
```
[✓] Flutter (Channel stable, 2.8.0, on macOS 12.1 21C52 darwin-arm, locale de-DE)
• Flutter version 2.8.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cf44000065 (11 days ago), 2021-12-08 14:06:50 -0800
• Engine revision 40a99c5951
• Dart version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Platform android-32, build-tools 32.0.0
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[✓] Android Studio (version 2020.3)
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

The Dart and Flutter Plugins are installed in Android Studio. Seems not to be detected from flutter doctor:
* Dart (JetBrains) 203.8452
* Flutter (flutter.dev) 63.2.1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.