GetX CLI — Creating artifacts with the command tool

Kheronn K. Machado
2 min readMay 3, 2021

--

Combining several elements such as state management, route, and dependency injection allows a gain in productivity and performance in development.

In addition, there are several utility functions such as navigation, dialogs, internationalization, validators, all in the same package.

If you are starting to code in Flutter and are lost with state management, I strongly recommend looking at this library. Also, take the opportunity to see my articles.

Flutter and GetX — Creating an application for sharing resources

Part 1

Part 2

The purpose of this post is to present the command tool GetX CLI, which automates the creation of various artifacts such as controllers, views and pages. It is possible to build the project with the get structure or to generate an existing one.

Installing

To enable the tool I needed to include flutter in the command, staying in the terminal:

flutter pub global activate get_cli

versions of DART on my machine. The problem was in the older version set in the environment variable.

When trying to install the error appeared Can’t load Kernel binary: Invalid kernel binary format version.

The solution was to uninstall the dart-SDK that I had done some time ago and change the path in the variable.

It was like this:

C: \ dart-sdk \ bin

It was:

C: \ flutter \ bin \ cache \ dart-sdk \ bin

Notice that it was below the installation of the flutter. You also need to include the cache in Path pub, something like:

C: \ Users \ UserName \ AppData \ Local \ Pub \ Cache \ bin

In this way, I installed Get_CLI without errors and avoided even closing the terminal unexpectedly after command execution.

Building the project

You can create your project using the command

get create project: my_project

That will be asked for some choices such as the type of the project and the organization of the files. I chose option 1 for all cases.

It will be creating a project with getting installed, a main file and routes, and a home module with controller, binding, and view.

For example, to create a page, just enter

get create page: contact

It will be generated in the modules folder, a contact folder with contato_view, contato_controller, and contato_binding.

I recorded a video showing (in Portuguese) the steps in the installation and generation.

In the documentation, you can find all the commands in more detail.

Thank you and see you.

--

--