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

Feature request: Option to convert all constructor parameters to required named parameters

Open ThinkDigitalSoftware opened this issue 5 years ago • 6 comments

If I have a widget like the following,

class MyWidget extends StatelessWidget {
  final arg1, arg2, arg3; // I know this is cringy, it's just for the sake of example.
  MyWidget(this.arg1, this.arg2, this.arg3); // same with this.
}

or


class MyWidget extends StatelessWidget {
  final arg1, arg2, arg3; // I know this is cringy, it's just for the sake of example.
  MyWidget({this.arg1, this.arg2, this.arg3}); // same with this.
}

can you provide an option to convert the parameters to required named parameters in one fell swoop?


class MyWidget extends StatelessWidget {
  final arg1, arg2, arg3; // I know this is cringy, it's just for the sake of example.
  MyWidget({@required this.arg1, @required this.arg2, @required this.arg3}); // same with this.
}

ThinkDigitalSoftware avatar May 04 '19 23:05 ThinkDigitalSoftware

This would be a fantastic refactor. I've manually performed this refactor dozens of times.

jacob314 avatar May 06 '19 16:05 jacob314

Yup. It would be nice to have the choice when creating them from the intellisense when declaring final variables and from the generate constructor option as well, although that would be secondary.

ThinkDigitalSoftware avatar May 06 '19 17:05 ThinkDigitalSoftware

@pq @scheglov, fyi for possible future text editing refactorings

devoncarew avatar May 20 '19 17:05 devoncarew

Hi, any update on this? I think many, as myself, expect to use this feature. Thank you.

vietstone-ng avatar Sep 08 '21 18:09 vietstone-ng

This should at least work when adding a not-yet-present final field to a constructor via the quick fix

Lootwig avatar Oct 02 '21 09:10 Lootwig

Any updates on this?

Ruben2112 avatar Mar 17 '22 18:03 Ruben2112