Assists
DCM provides a set of useful assists to speed up the refactoring process.
All listed assists are supported by both VS Code and IntelliJ / AS.
Wrap with ...
Wrap with custom widget assist allows you to set up the list of widgets that will be suggested to you when you call the assist menu in the IDE and a widget instance creation is selected.
This assist works close to the default "Wrap with Column" and "Wrap with Row", but is fully configurable to meet your 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 support 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
resulting in MyOtherWidget
be only suggested if a selected widget is an instance of MyListWidget
or its subclass. When this option is selected, the following code will be inserted MyListWidget(children: [...])
.
Extract class to a new file
Extract class to a new file assist allows you to quickly move the selected class to a new file.