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

add an assist to convert a constructor parameter to a field (w/ initializer) #48970

Open
pq opened this issue May 6, 2022 · 1 comment
Open
Labels
analyzer-editing-experience analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented May 6, 2022

From flutter-insiders feedback:

  • When you extract a widget class, or add a new constructor parameter to an existing widget class via quick fix, what you end up in is this:
    Constructor({String newVar});

However, below is where you want to get to and you have to edit the above manually to get to this below:
Constructor({required this.newVar});
String newVar;

It would be nice to have one or more refactor options that take us from the second one to the first one, such as "assign to a new field", "make required", etc.

@pq pq added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request analyzer-quick-fix type-enhancement A request for a change that isn't a bug analyzer-editing-experience labels May 6, 2022
@bwilkerson
Copy link
Member

Note that there is work to consider for the existing quick fix(es), assuming we can identify which ones. Minimally, it should make the parameter required when in a null-safe library. But if there is anything that would indicate that a field is what the user is likely to want we should create the field directly without requiring a second step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-editing-experience analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants