flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Missing 'add key parameter' refactoring on const constructors

Open jsiedentop opened this issue 3 years ago • 1 comments

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

jsiedentop avatar Dec 19 '21 17:12 jsiedentop

This should be added to dart-lang/sdk, since it is a feature request for the analyzer. I tried to move it but that no longer works.

stevemessick avatar Dec 20 '21 21:12 stevemessick