Flutter GetX CLI: Simplifying Your App Development Process
Hi readers!
Today I'm gonna share my experience generate flutter project with GetX CLI.
Without any futher, let's go to your terminal.
Create new folder to new project.
mkdir name_project
Next step you can open your project.
cd name_project
Let's create new flutter project on this folder.
flutter create .
# or if you only want to generate ios and android only
# do this command
flutter create --platforms=ios,android -e .
Now time to install get_cli, in this case I'm gonne use version 1.6 because not having error.
flutter pub global activate get_cli 1.6.0
Next step is rewrite our flutter project with getx pattern.
get init
You can choose GetX pattern.
get init
--> 1) GetX Pattern (by Kauê)
2) CLEAN (by Arktekko)
Next just select yes to convert old flutter template to getx pattern.
Your lib folder is not empty. Are you sure you want to overwrite your application?
WARNING: This action is irreversible
--> 1) Yes!
2) No
Done! Your project now fully with getx pattern.
✓ 'Package: get installed!
✓ File: main.dart created successfully at path: lib/main.dart
✓ File: home_controller.dart created successfully at path: ./lib/app/modules/home/controllers/home_controller.dart
✓ File: home_view.dart created successfully at path: ./lib/app/modules/home/views/home_view.dart
✓ File: home_binding.dart created successfully at path: ./lib/app/modules/home/bindings/home_binding.dart
✓ File: app_routes.dart created successfully at path: lib/app/routes/app_routes.dart
✓ File: app_pages.dart created successfully at path: lib/app/routes/app_pages.dart
✓ home route created successfully.
✓ Home page created successfully.
✓ GetX Pattern structure successfully generated.
Enjoy the pattern!
Next you can explore cli command more on the documentation.
// To install:
pub global activate get_cli
// (to use this add the following to system PATH: [FlutterSDKInstallDir]\bin\cache\dart-sdk\bin
flutter pub global activate get_cli
// To create a flutter project in the current directory:
// Note: By default it will take the folder's name as project name
// You can name the project with `get create project:my_project`
// If the name has spaces use `get create project:"my cool project"`
get create project
// To generate the chosen structure on an existing project:
get init
// To create a page:
// (Pages have controller, view, and binding)
// Note: you can use any name, ex: `get create page:login`
// Nota: use this option if the chosen structure was Getx_pattern
get create page:home
// To create a screen
// (Screens have controller, view, and binding)
// Note: you can use any name, ex: `get screen page:login`
// Nota: use this option if the chosen structure was CLEAN (by Arktekko)
get create screen:home
// To create a new controller in a specific folder:
// Note: you don't need to reference the folder,
// Getx will search automatically for the home folder
// and add your controller there.
get create controller:dialogcontroller on home
// To create a new view in a specific folder:
// Note: you don't need to reference the folder,
// Getx will automatically search for the home folder
// and insert your view there.
get create view:dialogview on home
// To create a new provider in a specific folder:
get create provider:user on home
// To generate a localization file:
// Note: 'assets/locales' directory with your translation files in json format
get generate locales assets/locales
// To generate a class model:
// Note: 'assets/models/user.json' path of your template file in json format
// Note: on == folder output file
// Getx will automatically search for the home folder
// and insert your class model there.
get generate model on home with assets/models/user.json
//to generate the model without the provider
get generate model on home with assets/models/user.json --skipProvider
//Note: the URL must return a json format
get generate model on home from "https://api.github.com/users/CpdnCristiano"
// To install a package in your project (dependencies):
get install camera
// To install several packages from your project:
get install http path camera
// To install a package with specific version:
get install path:1.6.4
// You can also specify several packages with version numbers
// To install a dev package in your project (dependencies_dev):
get install flutter_launcher_icons --dev
// To remove a package from your project:
get remove http
// To remove several packages from your project:
get remove http path
// To update CLI:
get update
// or `get upgrade`
// Shows the current CLI version:
get -v
// or `get -version`
// For help
get help
Thanks for read!
See ya on the next article!