/vscode-dart-build-runner-tools

Simplify your Dart development by running build_runner commands on specific files directly from the VS Code context menu.

Primary LanguageTypeScriptMIT LicenseMIT

build_runner VS Code Tools marketplace gh

Bring build_runner to your context menu. Shorten code generation times by building / watching specific files instead of the whole codebase in just two clicks.

vscode_showcase_part

Features

Menu

You can quickly run build_runner on either the whole workspace or on the active file through a build_runner menu. Open it by using a predefined keybinding ctrl+B + ctrl+R:

Menu

File context menu

If you want to run build_runner on a specific file, e.g. user.g.dart, simply right click the file and select the command you need, Build This / Watch This.

  • Build This: Regenerate the code for specified files directly targeting it with build_runner.
  • Watch This: Continuously monitor and regenerate code for specified files, automatically applying changes as you work.

You can also run build_runner on part files. No, there's don't need to multiselect all the files: the extension will do it for you. Just select the main file, such as user.dart, and the extension will gather all the associated part files, like user.freezed.dart and user.g.dart, and will run the command on those files.

  • Build Parts: Regenerate the code for parts of selected files.
  • Watch Parts: Continuously monitor and regenerate code for parts of specified files, automatically applying changes as you work.
Context menu

How does it work?

build_runner has a parameter build-filter that allows to specify which files to include for code generation.

dart build_runner build --build-filter=lib/user.g.dart

...and instead of regenerating the whole codebase, it will only regenerate lib/user.g.dart. Although running this command with terminal is not always convenient (especially if you want to run it on multiple files). This VS Code extension puts this command to your context menu. So just right click the needed files, select the required command and you're covered.

Once ran, it collects required files (part directives for part commands and selected files for this commands) and exectues the build/watch command in a new terminal window.

Important: Generated files must be used, not source files. E.g. if you have a user.dart that is used to generate user.freezed.dart class, the freezed class must be used as a parameter.

FAQ

How do I delete-conflicting-outputs?

If you want to add / remove this flag, you can enable / disable it in the settings of this extension. Or you can open the command palette and run Enable / Disable delete conflicting outputs command.

Can I run this on folders?

Yes, you can run this on both files and folders. Speaking of folders, only the part type of commands is supported. It checks all the files within a folder (and subfolders), collects the part directives and runs a build_runner.

vscode_showcase_folder

Is multiselect supported?

Yes, you can run this command on multiple files / folders at once.

vscode_showcase_multiselect

Can I run this in parallel?

Yes, the command is ran in a new terminal window each time it is executed. Meaning that you can run the watch command on the File A and then run the build command on the File B. For your convenience, you can rename terminal windows yourself to not mix them up.

vscode_showcase_parallel