Improve your productivity with Fast.cli 🔥
Hi everyone! My name is Alfredo, I’m Flutter developer in HandCash and I co-organize Flutterconf and GDGMarbella, in Spain. In this article, I´m going to show how to optimize your time making projects in Flutter.
If you have worked with Flutter, you know you can create the scaffold project for Flutter apps using the Flutter CLI
$ flutter create …
And later, you can start implementing dependencies that will be used in the project , like flutter_bloc, freezed, url_launcher… Searching in pub.dev and paste in pubspec.yaml
Then, you start creating your folder structure below lib, like domain, data_access, ui… And recursively, the subfolders inside their folders.
Very bored and repetitive, so I started searching how to automate it and I found this project.
Fast.cli project 🤖
Fast.cli is a tool, made by pbissonho, to create a custom CLI that can handle all of this task.
This tool works using plugins like the VSCode system. You can create your own plugins and share with all people that use this tool, it is amazing!
Currently, creating your plugin, you will have this features:
- Templates generator
- Application Scaffold generator
- Snippet generator for Visual Studio Code
- Custom commands
- Standard line commands (Some commands already included in the CLI)
Amazing!! Let’s see how to install it.
Installation
You have to install the Dart SDK in your system to continue with these steps. When you have installed and configured the environment, you have to only write:
$ pub global activate fast
And add this folder to your environment in your bash, this is a example if you use zsh
echo export PATH="$PATH:$HOME/.fastcli/bin/" >> .zshrc
Clean-bloc project đź›
This is the perfect tool to achieve my goal, create a tool to implement all dependencies and scaffold at all of my projects.
Using this tool, I made a plugin for this automate, you can see here and all PR are welcome!
Installation
In order to install my plugin, first you need to install Fast.cli. After, you only have to write:
$ fast plugin add git git@github.com:alfredobs97/clean-bloc.git
And this is all! Now you can my plugin.
How to use it
The first approach to my plugin was:
I need to create a standard scaffold, following clean-architecture principles and add the dependencies that all projects need to use to create robust, scalable and efficiency Flutter apps.
In order to create this, I wrote the “bloc scaffold”
$ clean-bloc create --name <flutter_projet_name> --scaffold bloc
This command will create the normal Flutter app scaffold with this content in lib
And this follow dependencies:
flutter_bloc: ^6.0.5
freezed_annotation: ^0.12.0
logger: ^0.9.4
json_annotation: ^3.0.1
chopper: ^3.0.2
injector: ^1.0.9
build_runner: ^1.10.4
freezed: ^0.12.2
bloc_test: ^7.1.0
mockito: ^4.1.3
json_serializable: ^3.5.0
chopper_generator: ^3.0.6
Finally, you can forget the hell flutter command:
$ flutter pub run build_runner build
And use:
$ clean-bloc run build
Make your own plugin!
This approach could be useful for developers that use bloc pattern and clean architecture but there are a lot of people using other patterns or guidelines so I recommend you create a plugin that optimizes your time!
Following my plugin structure or Fast.cli tutorial, you can implement your own plugins in easy mode. Adding VSCode snippets or templates.
Thanks to the Flutter/Dart community đź’™
This tool is a great example of how the community is growing and there are a lot of great and useful packages for your day a day.
I encourage you to contribute to the Fast.cli project, this has a great future helping us save time in new projects.
That’s all for today, thanks for reading and you can find me in Twitter where DM are open!
Follow FlutterConf account and GDGMarbella to stay tuned with new events of Flutter! đź’™
Thank you for your time and see you later! 👋🏼👋🏼