-->
VS Code supports easily running “tasks” defined in .vscode/tasks.json
. To get started, open the command palette and select the “Tasks: Configure Task” option. This will create the tasks.json
file if it doesn’t already exists.
Next, add the commands that you frequently use. Each task should have a command
, a label
, and args
.
To run one of these commands, open the command palette in VS Code and type “task {TASK_NAME}“. For example, to run flutter clean
, I could type “task Clean” into the command palette. All available options will appear after you type task like this:
Ensure that there is no ”>” in the command palette search bar or else the tasks will not appear.
At this point, you’re probable wondering why you would do this since you can easily type flutter clean
or flutter pub get
into the terminal. The true power of VS code tasks lies in the ability to create Compound tasks or tasks that will run in sequence.
To run both flutter clean
and flutter pub get
one after another using the command palette, we can add a third task to our tasks.json
that references the labels of the first two tasks:
You can string together as many tasks as you’d like using this method and make your life a whole lot easier.
In Android Studio:
+
buttonShell Script
Script file
or Script text
depending on the script you’re usingScript text
should be used for simple task combinations or commands.
Script file
should be used for longer scripts. To use this option, create a shell script file that ends in .sh
(ex. deploy.sh
). A typical script file will look something like this:
If you’d prefer not to use an IDE-specific solution like VS Code tasks, you can write your scripts in Dart like this:
Then you can run the file one of two ways:
dart run deploy.dart
Or…
copy path
dart {paste path}
Copyright © 2024 Code On The Rocks. All rights reserved.