Assists
DCM offers a set of useful assists to speed up the refactoring process.
All listed assists are supported by both VS Code and IntelliJ / Android Studio.
Wrap with a Custom Widget​
The "Wrap with Custom Widget" assist allows you to configure a list of widgets that will be suggested when you invoke the assist menu in the IDE and select a widget instance creation.
This assist works similarly to the default "Wrap with Column" and "Wrap with Row", but it is fully customizable to meet your specific needs.
Configuration Example​
To configure this assist, add the assists
entry to the dart_code_metrics
config section:
dart_code_metrics:
assists:
wrap-with:
- WidgetName
- MyOtherWidget
Each wrap-with
-list entry also supports extended config options:
prop
- the name of the property where the current widget should be passed (default ischild
).list
- a boolean flag indicating whether theprop
accepts an array of widgets (default isfalse
).target
- a class name, for which the widget should be suggested (default is unset).
Example of a more advanced config:
dart_code_metrics:
assists:
wrap-with:
- WidgetName
- MyOtherWidget:
prop: children
list: true
target: MyListWidget
In this example, MyOtherWidget
will only be suggested if the selected widget is an instance of MyListWidget
or its subclass. When this option is selected, the following code will be inserted: MyListWidget(children: [...])
.
Extract a Class to a New File​
The "Extract Class to a New File" assist allows you to quickly move the selected class to a new file.