...

/

Automation with Get CLI

Automation with Get CLI

Learn to automate tasks using Get CLI commands.

Overview

Get CLI automates a good chunk of tasks revolving around boilerplate. It helps us structure our project in a scalable way and provides commands to quickly generate files within that structure. Let’s see what this tool has to offer.

In this lesson, we’ll use get to execute commands. But getx works similarly, so feel free to use any of them.

Create project

To create a project, run the following command:

Press + to interact
get create project

Once this command is executed, it asks us questions like project’s name, company domain, whether to add a linter, etc. Then it generates a project for us just as the default Flutter project but configured to our answers.

We can also provide the project name directly.

Press + to interact
get create project:project_name

Replace project_name with the desired name and the new project will be created with that name.

Initialize the project structure

Creating the default Flutter project is fine, but what if we could structure the project in an organized and scalable way? Below is just the command we need!

Press + to interact
get init

This little command does tons of heavy lifting for us. When executed, it asks us to select either getx_pattern or clean architecture, and accordingly, it creates a project with dedicated folders for data, views, controllers, bindings, and navigation. Inside these folders, it creates files prefilled with boilerplate. It even installs the GetX package. This minimizes the friction and lets us get to the real work immediately.

Create a page

According to the project structure we choose, we can add a new page to the app by executing one of the two commands below. The only difference is in terminology. If we’re structuring the project using getx_pattern, we will use the page term. And if we’re sticking to the clean architecture, we will use the screen term.

Here, we are creating a page called login.

Press + to interact
get create page:login // when using getx_pattern
get create screen:login // when using clean

Creating a page does not mean just adding a widget class. In fact, this command generates all the necessary files and boilerplate relevant to the page’s business logic and navigation. Let us understand ...