Open In App

Flutter - Project Setup with GetX CLI Tool

Last Updated : 21 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will learn how to set up or file structure our Flutter project using get_cli. You might be aware of the GetX state management. If not, let us explain to you all the things so that you are familiar with these terms. State Management is to manage the things between 2 or more screens or in a complete app. It helps to create heavy applications and sustain data on every screen. GetX is one of the state management tools, dependency managers, and navigation managers that we are using in Flutter. Previously, it was limited to state management only. A command line interface (CLI) is a text-based interface where you can input commands that interact with a computer's operating system. Let's learn how to add get_cli to the Flutter project and maintain app structure, dependencies, and many more. In the time of automation, you should not create the UI structure manually when you can do it through a single command.

Step-by-Step Implementation

Step 1: Install the get_cli on your device

You can install the CLI on your system

Dart
flutter pub global activate get_cli

Step 2: Create a Flutter project

Create a new Flutter application using the command Prompt. To create a new app, write the following command and run it.

Dart
flutter create app_name


To know more about it refer this article: Creating a Simple Application in Flutter

Or you can create a project from get_cli

Dart
get create project

If you have an existing project, you can use the following command to generate the structure.

Dart
get init


It will ask you to choose one of the options below

  1. GetX Pattern (by Kauê)
  2. CLEAN (by Arktekko)

Choose "Getx pattern" by pressing "1" and Enter.

If your project's lib folder contains any code, then it will ask for your permission to override it. So, answer accordingly.

getx_cli

It will create a folder structure like this

folder_structure

Step 3: Create a page using the command

Create a page that will contain a controller, view, and binding with the page name that you provide.

Dart
get create page:page_name

It will create a folder structure like this.

file


It will have a view file where you will create a UI like a textfield, text, column, and row. Controllers will contain API calls and navigation, and data where you will set the data. Bindings are classes where we can declare our dependencies and then ‘bind’ them to the routes. From the below command, you can manage the app from the CLI, as you now have access to get commands. Let's understand how to handle different things

1. To generate a model file

Dart
get generate model on home with assets/models/user.json

Here assets/models/user.json is the kind of data for which you want to create the model file.

2. Add the package

Dart
get install http

Here, http is the package name you want to add to your project.

3. To remove the package

This is to remove the package from the app

Dart
get remove http

4. To generate a localization file

Dart
get generate locales assets/locales

assets/locales is the path name where we have to create a locales file.

5. To install the dev dependency

Dart
get install flutter_launcher_icons --dev

6. To update the get_cli

To update the get cli.

Dart
get update


You have successfully learnt the basics of get_cli from the above command. Hope you have understood all the things.


Next Article

Similar Reads