Skip to main content

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:

analysis_options.yaml
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 is child).
  • list - a boolean flag indicating whether the prop accepts an array of widgets (default is false).
  • target - a class name, for which the widget should be suggested (default is unset).

Example of a more advanced config:

analysis_options.yaml
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.