GetX Cli installation

Video Tutorial Address

Zero basic video tutorial address

Step 1: Install Cli scaffolding

Scaffolding is installed globally by using the command flutter pub global activate get_cli. This article uses Mac OS as an example.

JMdeMacBook-Pro:~ jm$ flutter pub global activate get_cli

Resolving dependencies...
+ _fe_analyzer_shared 25.0. 0
+ analyzer 2.2. 0
+ ansicolor 2.01.
+ archive 3.12.
+ args 2.2. 0
+ async 2.82.
+ charcode 1.31.
+ cli_dialog 0.5. 0
+ cli_menu 0.3. 0-nullsafety. 0
+ cli_util 0.33.
+ clock 1.1. 0
+ collection 1.15. 0
+ convert 3.01.
+ crypto 3.01.
+ dart_console 1.0. 0
+ dart_style 2.03.
+ ffi 1.12.
+ file 6.12.
+ get_cli 1.6. 0
+ glob 2.01.
+ http 0.133.
+ http_parser 4.0. 0
+ intl 0.17. 0
+ matcher 0.1211.
+ meta 1.7. 0
+ package_config 2.0. 0
+ path 1.8. 0
+ pedantic 1.111.
+ process_run 0.121.+1
+ pub_semver 2.0. 0
+ pubspec 2.01.
+ quiver 3.01.
+ recase 4.0. 0
+ source_span 1.81.
+ stack_trace 1.10. 0
+ string_scanner 1.1. 0
+ synchronized 3.0. 0
+ term_glyph 1.2. 0
+ typed_data 1.3. 0
+ uri 1.0. 0
+ version 2.0. 0
+ watcher 1.0. 0
+ win32 2.29.
+ yaml 3.1. 0
Downloading get_cli 1.6. 0. Downloading version2.0. 0. Downloading recase4.0. 0. Downloading pubspec2.01.. Downloading cli_menu0.3. 0-nullsafety. 0. Downloading cli_dialog0.5. 0. Downloading ansicolor2.01.. Downloading uri1.0. 0. Downloading process_run0.121.+1.. Downloading synchronized3.0. 0. Downloading dart_console1.0. 0. Downloading quiver3.01.. Downloading dart_style2.03.. Downloading analyzer2.2. 0. Downloading _fe_analyzer_shared25.0. 0. Downloading win322.29.. Building package executables... Built get_cli:get.
Installed executables get and getx.
Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):

export PATH="$PATH":"$HOME/. Pub - cache/bin "Activated get_cli 1.6.0.Copy the code

Step 2: Set the environment variables

Generally, Mac environment variables are set through the root directory. Bash_profile.

#getX
export PATH="$PATH":"$HOME/.pub-cache/bin"
Copy the code

Step 3: Validate your environment variables

We can use source plus path to apply to environment variables.

JMdeMacBook-Pro:~ jm$ source "/Users/jm/.bash_profile"
Copy the code

Step 4: Verify whether the installation is successful

Let’s see if we can print the following through get command. If so, congratulations on your successful installation.

JMdeMacBook-Pro:~ jm$ get

List available commands:

  create:  
    controller:  Generate controller
    page:  Use to generate pages
    project:  Use to generate new project
    provider:  Create a new Provider
    screen:  Generate new screen
    view:  Generate view
  generate:  
    locales:  Generate translation file from json files
    model:  generate Class model from json
  help:  Show this help
  init:  generate the chosen structure on an existing project:
  install:  Use to install a package in your project (dependencies):
  remove:  Use to remove a package in your project (dependencies):
  sort:  Sort imports and format dart files
  update:  To update GET_CLI
  --version:  Shows the current CLI version' Time: 1814 MillisecondsCopy the code

Cli Creation Project

We can create the project by getting Create Project,

JMdeMacBook-Pro:getx jm$ get create project
Copy the code

We then select create Flutter Project as prompted

-->   1) Flutter Project
      2) Get Server
Copy the code

After selecting, you need to input the project name, company domain name, select iOS language, Select Android language, whether air security, whether verification, and then you will start to create the project for us.

JMdeMacBook-Pro:getx jm$ get create project
-->   1) Flutter Project
      2) Get Server
? what is the name of the project? getx_example
? What is your company's domain?  Example: com.yourcompany  com.jimi

what language do you want to use on ios?

      1) Swift
-->   2) Objective-C

what language do you want to use on android?

      1) Kotlin
-->   2) Java

Do you want to use null safe?

-->   1) Yes!
      2) No

do you want to use some linter?

      1) no
      2) Pedantic [Deprecated]
      3) Effective Dart [Deprecated]
-->   4) Dart Recommended

Running `flutter create /Users/jm/Desktop/Project/getx/getx_example` …

$ flutter create --no-pub -i objc -a java --org com.jimi /Users/jm/Desktop/Project/getx/getx_example
Creating project ....
  test/widget_test.dart (created)
  pubspec.yaml (created)
  README.md (created)
  lib/main.dart (created)
  windows/runner/flutter_window.cpp (created)
  windows/runner/utils.h (created)
  windows/runner/utils.cpp (created)
  windows/runner/runner.exe.manifest (created)
  windows/runner/CMakeLists.txt (created)
  windows/runner/win32_window.h (created)
  windows/runner/Runner.rc (created)
  windows/runner/win32_window.cpp (created)
  windows/runner/resources/app_icon.ico (created)
  windows/runner/main.cpp (created)
  windows/runner/resource.h (created)
  windows/runner/flutter_window.h (created)
  windows/flutter/CMakeLists.txt (created)
  windows/.gitignore (created)
  windows/CMakeLists.txt (created)
  ios/Runner.xcworkspace/contents.xcworkspacedata (created)
  ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings (created)
  ios/Runner/Info.plist (created)
  ios/Runner/Assets.xcassets/LaunchImage.imageset/[email protected] (created)
  ios/Runner/Assets.xcassets/LaunchImage.imageset/[email protected] (created)
  ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md (created)
  ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json (created)
  ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] (created)
  ios/Runner/Base.lproj/LaunchScreen.storyboard (created)
  ios/Runner/Base.lproj/Main.storyboard (created)
  ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata (created)
  ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings (created)
  ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (created)
  ios/Flutter/Debug.xcconfig (created)
  ios/Flutter/Release.xcconfig (created)
  ios/Flutter/AppFrameworkInfo.plist (created)
  ios/.gitignore (created)
  getx_example.iml (created)
  .gitignore (created)
  web/favicon.png (created)
  web/index.html (created)
  web/manifest.json (created)
  web/icons/Icon-maskable-512.png (created)
  web/icons/Icon-192.png (created)
  web/icons/Icon-maskable-192.png (created)
  web/icons/Icon-512.png (created)
  .metadata (created)
  macos/Runner.xcworkspace/contents.xcworkspacedata (created)
  macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (created)
  macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png (created)
  macos/Runner/DebugProfile.entitlements (created)
  macos/Runner/Base.lproj/MainMenu.xib (created)
  macos/Runner/MainFlutterWindow.swift (created)
  macos/Runner/Configs/Debug.xcconfig (created)
  macos/Runner/Configs/Release.xcconfig (created)
  macos/Runner/Configs/Warnings.xcconfig (created)
  macos/Runner/Configs/AppInfo.xcconfig (created)
  macos/Runner/AppDelegate.swift (created)
  macos/Runner/Info.plist (created)
  macos/Runner/Release.entitlements (created)
  macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  macos/Runner.xcodeproj/project.pbxproj (created)
  macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (created)
  macos/Flutter/Flutter-Debug.xcconfig (created)
  macos/Flutter/Flutter-Release.xcconfig (created)
  macos/.gitignore (created)
  ios/Runner/AppDelegate.h (created)
  ios/Runner/main.m (created)
  ios/Runner/AppDelegate.m (created)
  ios/Runner.xcodeproj/project.pbxproj (created)
  android/app/src/profile/AndroidManifest.xml (created)
  android/app/src/main/res/mipmap-mdpi/ic_launcher.png (created)
  android/app/src/main/res/mipmap-hdpi/ic_launcher.png (created)
  android/app/src/main/res/drawable/launch_background.xml (created)
  android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (created)
  android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (created)
  android/app/src/main/res/values-night/styles.xml (created)
  android/app/src/main/res/values/styles.xml (created)
  android/app/src/main/res/drawable-v21/launch_background.xml (created)
  android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (created)
  android/app/src/main/AndroidManifest.xml (created)
  android/app/src/debug/AndroidManifest.xml (created)
  android/gradle/wrapper/gradle-wrapper.properties (created)
  android/gradle.properties (created)
  android/.gitignore (created)
  android/settings.gradle (created)
  android/app/build.gradle (created)
  android/app/src/main/java/com/jimi/getx_example/MainActivity.java (created)
  android/build.gradle (created)
  android/getx_example_android.iml (created)
  analysis_options.yaml (created)
  .idea/runConfigurations/main_dart.xml (created)
  .idea/libraries/Dart_SDK.xml (created)
  .idea/libraries/KotlinJavaRuntime.xml (created)
  .idea/modules.xml (created)
  .idea/workspace.xml (created)
  linux/main.cc (created)
  linux/my_application.h (created)
  linux/my_application.cc (created)
  linux/flutter/CMakeLists.txt (created)
  linux/.gitignore (created)
  linux/CMakeLists.txt (created)
Wrote 129 files.

All done!
In order to run your application, type:

  $ cd .
  $ flutter run

Your application code is in ./lib/main.dart.


Running `flutter pub get` …

$ flutter pub get
Running "flutter pub get" in getx_example...                       898ms
$ dart migrate --apply-changes --skip-import-check
Migrating /Users/jm/Desktop/Project/getx/getx_example

See https://dart.dev/go/null-safety-migration for a migration guide.

Analyzing project...
All sources appear to be already migrated.  Nothing to do.
✖  + HandshakeException: Connection terminated during handshake

✓  File: analysis_options.yaml created successfully at path: analysis_options.yaml
-->   1) GetX Pattern (by Kauê)
      2) CLEAN (by Arktekko)

Your lib folder is not empty. Are you sure you want to overwrite your application? 
 WARNING: This action is irreversible

-->   1) Yes!
      2) No
✓  'Package: getinstalled! ✓ 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: 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 successfullyPattern structure successfully generated.

Running `flutter pub get`... $ flutter pubget
Running "flutter pub get" in getx_example...                       968ms

Time: 53925 Milliseconds
Copy the code

If the preceding information is displayed, the project is successfully created through the Cli.

Cli Creation Page

The first is Getx_pattern

We can quickly create a page by getting Create Page :login. This page has controller, View, Binding, routes configuration, etc. The structure is Getx_pattern

JMdeMacBook-Pro:getx_example jm$ getCreate page:login ✓ File: login_controller. Dart created successfully at path: . / lib/app/modules/login/controllers/login_controller dart ✓ File: login_view. Dart created successfully at path: . / lib/app/modules/login/views/login_view dart ✓ File: login_binding. Dart created successfully at path: . / lib/app/modules/login/bindings/login_binding dart ✓ login route created successfully. ✓ login page is created successfully. Time:453 Milliseconds

JMdeMacBook-Pro:getx_example jm$ 
Copy the code

Number two: CLEAN

We can quickly create a page by getting Create Page :login. This page has controller, View, Binding, routes configuration, etc. The structure is CLEAN.

JMdeMacBook-Pro:getx_example jm$ getCreate screen:name ✓ File: name.controller. Dart created successfully at path: . / lib/presentation/name/controllers/name. The controller. The dart ✓ File: name. The screen. The dart created successfully at path: . / lib/presentation/name/name. The screen. The dart ✓ File: name. Controller. Binding. The dart created successfully at path: Lib/infrastructure/navigation/bindings/controllers/name. The controller. The binding. The dart ✓ File: Routes. The dart created successfully at path: lib/infrastructure/navigation/routes. The dart ✓ File: routes.dart created successfully at path: Lib/infrastructure/navigation/routes. The dart ✓ name route created successfully. ✓ File: navigation.dart created successfully at path: Lib/infrastructure/navigation/navigation. The dart ✓ Name navigation added successfully. The Time:482 Milliseconds
Copy the code

Creating a Controller on the Cli

We can quickly create a controller for an existing page by getting Create Controller: Login, and it also re-creates the controller’s life cycle and initialization method.

get create controller:another onHome ✓ File: another_controller. Dart created successfully at path: . / lib/app/modules/home/controllers/another_controller dart ✓ The Another has had been added to The binding at The path: lib/app/modules/home/bindings/home_binding.dart' Time: 387 Milliseconds JMdeMacBook-Pro:getx_example jm$Copy the code

Cli to create the View

If we just want to create a separate View, we can do this by getting Create View :alogin on Login.

 get create view:alogin onThe login ✓ File: alogin_view. Dart created successfully at path:. / lib/app/modules/login/views/alogin_view dart Time:378 Milliseconds

JMdeMacBook-Pro:getx_example jm$ 
Copy the code

Create the Provider Cli

If we need to create GetConnect, we can do so by getting Create Provider: bLogin on Login.

JMdeMacBook-Pro:getx_example jm$ get create provider:blogin onLogin ✓ File: blogin_provider. Dart created successfully at path: ./lib/app/modules/login/providers/blogin_provider.dart Time:357 Milliseconds

JMdeMacBook-Pro:getx_example jm$ 
Copy the code

Cli Creation Internationalization

If we need to internationalize the application, we can create it by getting Generate Locales assets/locales.

JMdeMacBook-Pro:getx_example jm$ getGenerate locales assets/locales ✓ File: locales. G.art created successfully at path: Lib/generated/locales. G.d art ✓ locale files generated successfully. The Time:416 Milliseconds

JMdeMacBook-Pro:getx_example jm$ 
Copy the code

The Cli generates a JSON model

The first: not only create model classes, but also provide providers

If we need to generate a model for a JSON file, we can do this by getting generate model on home with assets/ Models /user.json

JMdeMacBook-Pro:getx_example jm$ get generate model on home withAssets /models/user.json ✓ File: user_Model. dart created successfully at path: . / lib/app/modules/home/user_model dart ✓ File: user_provider. Dart created successfully at path: ./lib/app/modules/home/providers/user_provider.dart Time:499 Milliseconds

JMdeMacBook-Pro:getx_example jm$ 
Copy the code

Second: generate only model classes

JMdeMacBook-Pro:getx_example jm$ get generate model on login withAssets/Models /user.json --skipProvider ✓ File: user_Model. Dart created successfully at path: ./lib/app/modules/login/user_model.dart Time:408 Milliseconds
Copy the code

Third: generate model classes by wiring

JMdeMacBook-Pro:getx_example jm$ get generate model on home from "https://api.github.com/users/CpdnCristiano"
? Could not set the model name automatically, which name doyou want to use? GithubHome ✓ File: github_home_model. Dart created successfully at path: . / lib/app/modules/home/github_home_model dart ✓ File: github_home_provider. Dart created successfully at path: ./lib/app/modules/home/providers/github_home_provider.dart Time:14033 Milliseconds
Copy the code

Cli Installation Package (Dependencies)

First: Install the latest version directly

JMdeMacBook-Pro:getx_example jm$ get install dio

Installing package "dio"... ✓'Package: dio installed! Running 'flutter pub get'... $ flutter pub get Running "flutter pub get" in getx_example... 2656 ms Time: 5815 MillisecondsCopy the code

Second: Install multiple packages at the same time

JMdeMacBook-Pro:getx_example jm$ get install path dio

Installing package "path"... ✓'Package: path installed! Installing package "dio"... ✓ 'Package: dio installed!

Running `flutter pub get`... $ flutter pubget
Running "flutter pub get" in getx_example...                       732ms

Time: 7146 Milliseconds
Copy the code

Third: Install the customized package

JMdeMacBook-Pro:getx_example jm$ get install prodiver:5.0. 0

Installing package "prodiver"... ✓'Package: prodiver installed!
Copy the code

Cli Installation Package (dev_dependencies)

We can install flutter_launcher_icons –dev to install the packages we rely on for development

JMdeMacBook-Pro:getx_example jm$ get install flutter_launcher_icons --dev


The [--dev] is not necessary


Installing package "flutter_launcher_icons"... ✓'Package: flutter_launcher_icons installed!
Copy the code

Cli uninstall packages

The first option is to uninstall an installation package

JMdeMacBook-Pro:getx_example jm$ get remove http

Removing package: "http"


Package: http is not installed in this application


Running `flutter pub get`... $ flutter pubget
Running "flutter pub get" in getx_example...                       772ms

Time: 2641 Milliseconds

Copy the code

Second: Uninstall multiple packages at the same time

JMdeMacBook-Pro:getx_example jm$ get remove dio path

Removing package: "dio"

✓  Package: dio removed!

Removing package: "path"

✓  Package: path removed!

Running `flutter pub get`... $ flutter pubget
Running "flutter pub get" in getx_example...                     1.085ms

Time: 3142 Milliseconds
Copy the code

Cli Update scaffolding

Scaffolding can be updated with get Update

JMdeMacBook-Pro:getx_example jm$ get update

Latest version of get_cli already installed


Time: 3315 Milliseconds
Copy the code

Cli View the version

We can view the version number of the current scaffold by using get-v

JMdeMacBook-Pro:getx_example jm$ getThe -v ░ █ █ █ █ █ █ ╗ ░ █ █ █ █ █ █ █ ╗ █ █ █ █ █ █ █ █ ╗ ░ █ █ █ █ █ ╗ ░ █ █ ╗ ░ ░ ░ ░ ░ ░ █ █ ╗ █ █ ╔ ═ ═ ═ ═ ╝ ░ █ █ ╔ ═ ═ ═ ═ ╝ ╚ ═ ═ █ █ ╔ ═ ═ ╝ █ █ ╔ ═ ═ █ █ ╗ █ █ ║ ░ ░ ░ ░ ░ ░ █ █ ║ █ █ ║ ░ ░ █ █ ╗ ░ █ █ █ █ █ ╗ ░ ░ ░ ░ ░ █ █ ║ ░ ░ ░ █ █ ║ ░ ░ ╚ ═ ╝ █ █ ║ ░ ░ ░ ░ ░ ░ █ █ ║ █ █ ║ ░ ░ ╚ █ █ ╗ █ █ ╔ ═ ═ ╝ ░ ░ ░ ░ ░ █ █ ║ ░ ░ ░ █ █ ║ ░ ░ █ █ ╗ █ █ ║ ░ ░ ░ ░ ░ ░ █ █ ║ ╚ █ █ █ █ █ █ ╔ ╝ █ █ █ █ █ █ █ ╗ ░ ░ ░ █ █ ║ ░ ░ ░ ╚ █ █ █ █ █ ╔ ╝ █ █ █ █ █ █ █ ╗ █ █ ║ ░ ╚ ═ ═ ═ ═ ═ ╝ ░ ╚ ═ ═ ═ ═ ═ ═ ╝ ░ ░ ░ ╚ ═ ╝ ░ ░ ░ ░ ╚ ═ ═ ═ ═ ╝ ░ ╚ ═ ═ ═ ═ ═ ═ ╝ ╚ ═ ╝ Version:1.6. 0

Time: 148 Milliseconds
Copy the code

Cli help

When we forget how to use the command, we can use get help to see the help.

JMdeMacBook-Pro:getx_example jm$ get help

List available commands:

  create:  
    controller:  Generate controller
    page:  Use to generate pages
    project:  Use to generate new project
    provider:  Create a new Provider
    screen:  Generate new screen
    view:  Generate view
  generate:  
    locales:  Generate translation file from json files
    model:  generate Class model from json
  help:  Show this help
  init:  generate the chosen structure on an existing project:
  install:  Use to install a package in your project (dependencies):
  remove:  Use to remove a package in your project (dependencies):
  sort:  Sort imports and format dart files
  update:  To update GET_CLI
  --version:  Shows the current CLI version' Time: 94 MillisecondsCopy the code

conclusion

The above is a practice and summary of Cli scaffolding commands, which can be implemented with Cli rather than manually creating the structure yourself.