Idea: Extract Widget
See original GitHub issueHow it works: Highlight some widgets in a large widget build
tree you’d like to start breaking down. Currently, you can easily extract these as a method in the current class using the “extract method” action. However, I often find myself creating a StatelessWidget out of this selection instead of a method and have to do that part manually. It would be very handy if you could “extract widget”.
This would allow you to create a Stateless Widget, with a constructor and fields that match the necessary params. For example, if you extracted a piece of Code, and it required a Todo
with the variable name todo
, the StatelessWidget would extract a final Todo todo
field and a Constructor to match. The build method would return the contents of your highlighted selection.
After creating the class, it would replace your current highlighted selection with the new MyTodoWidget(todo)
;
Essentially, this would just be a slightly different extraction than a method.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
The feature is implemented. You can extract either a widget instance creation or a method that return a widget. It coverts any read local variables and fields into extract widget fields and constructor parameters.
@jwren