Saving time typing flutter cli commands

Simon Auer
2 min readJun 26, 2022

--

Flutter is amazing, but sadly the cli is not really straight forward and commands get pretty long. This is why I have created a small bash script with my most used flutter commands and want to share it with you guys.

This bash script can of course used for every other cli tool (react, javascript, angular, …) or even other tasks as well. Just take it as an inspiration. :)

Oh and please share your scripts or usecases. Would love to hear what you guys would use it for! :)

Disclaimer:
The file here is just a start and not meant for you to copy it 1:1, because it will change and contain commands specific to me.
It is meant as a concept basis for you to build upon.

Everything should work fine on Unix and OSX. Maybe it works in Windows as well, but not sure about it.
(PRs with instructions are welcome in the git repo)

You can find the repo here: PRs and feedback are welcome.
https://github.com/SimonErich/bash-shortcuts-flutter/

## How to use

Just download the bash script:

```bash
wget https://github.com/SimonErich/bash-shortcuts-flutter/blob/main/flu.sh ~/flu.sh
chmod +x ~/flu.sh
```

## Linux & OSX

Add it to your profile file. (`~/.zshrc` or `~/.bashrc` — depending on your shell):

```
source ~/flu.sh
```

## You are good to go

Now close your terminal window and open it again.
Now you should just be able to call the commands in the document:

### flu get

Shortcut for the command `flutter pub get`

### flu analyze

Shortcut for the command `flutter analyze`

### flu test

Shortcut for the command `flutter test`

### flu format

Shortcut for the command `flutter format .` (just analyzes, but does not fix)

### flu format fix

Shortcut for the command `flutter format — fix .` (analyzes and fixes problems)

### flu runner

Shortcut for the command `flutter pub run build_runner — delete-conflicting-outputs`

### flu runner

Shortcut for the command `flutter pub run build_runner — delete-conflicting-outputs`

### flu runner watch

Shortcut for the command `flutter pub run build_runner watch — delete-conflicting-outputs`

## Further reading

The script was created based on the following article: (with more explanation on syntax and workings)
https://dev.to/eddeee888/how-to-write-a-bash-shortcut-script-to-enhance-your-terminal-experience-5898

### Specific commands to our environment

May not apply to your setup.

#### flu widgetbook-build

Shortcut for the command `flutter run -t lib/widgetbook.widgetbook.dart -d chrome — web-renderer html — `

Let me know if you have other useful generic commands.
There are a few for sure and I will extend the git repo with them over the next couple of days, but these 3 here have been annoying me for a while.

Do you have any alternative solutions or approaches?
Let me know!

--

--

Simon Auer

I develop software using modern technologies like Laravel, React, React Native and Flutter. Follow me also on https://twitter.com/SimonEritsch