Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

documentation languages
pt_br en_us – this file zh_cn

official cli for the getx™ framework.

// to install:
pub global activate get_cli 
// (to use this add the following to system path: [fluttersdkinstalldir]bincachedart-sdkbin

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

exploring the cli

let’s explore the existing commands in the cli

create project

  get create project

using to generate a new project, you can choose between flutter and get_server, after creating the default directory, it will run a get init next command

init

  get init

use this command with care it will overwrite all files in the lib folder.
it allows you to choose between two structures, getx_pattern and clean.

create page

  get create page:name

this command allows you to create modules, it is recommended for users who chose to use getx_pattern.

creates the view, controller and binding files, in addition to automatically adding the route.

you can create a module within another module.

  get create page:name on other_module

when creating a new project now and use on to create a page the cli will use children pages.

create screen

  get create screen:name

similar to the create page, but suitable for those who use clean

create controller

  get create controller:dialog on your_folder

create a controller in a specific folder.

using with option
you can now create a template file, the way you prefer.

run

  get create controller:auth with examples/authcontroller.dart on your_folder

or with url
run

  get create controller:auth with 'https://raw.githubusercontent.com/jonataslaw/get_cli/master/samples_file/controller.dart.example' on your_folder

input:

@import

class @controller extends getxcontroller {
  final  email = ''.obs;
  final  password = ''.obs;
  void login() {
  }

}

output:

import 'package:get/get.dart';

class authcontroller extends getxcontroller {
  final email = ''.obs;
  final password = ''.obs;
  void login() {}
}

create view

  get create view:dialog on your_folder

create a view in a specific folder

generate locates

create the json language files in the assets/locales folder.

input:

pt_br.json

{
  "buttons": {
    "login": "entrar",
    "sign_in": "cadastrar-se",
    "logout": "sair",
    "sign_in_fb": "entrar com o facebook",
    "sign_in_google": "entrar com o google",
    "sign_in_apple": "entrar com a  apple"
  }
}

en_us.json

{
  "buttons": {
    "login": "login",
    "sign_in": "sign-in",
    "logout": "logout",
    "sign_in_fb": "sign-in with facebook",
    "sign_in_google": "sign-in with google",
    "sign_in_apple": "sign-in with apple"
  }
}

run :

get generate locales assets/locales

output:

abstract class apptranslation {

  static map<string, map<string, string>> translations = {
    'en_us' : locales.en_us,
    'pt_br' : locales.pt_br,
  };

}
abstract class localekeys {
  static const buttons_login = 'buttons_login';
  static const buttons_sign_in = 'buttons_sign_in';
  static const buttons_logout = 'buttons_logout';
  static const buttons_sign_in_fb = 'buttons_sign_in_fb';
  static const buttons_sign_in_google = 'buttons_sign_in_google';
  static const buttons_sign_in_apple = 'buttons_sign_in_apple';
}

abstract class locales {

  static const en_us = {
   'buttons_login': 'login',
   'buttons_sign_in': 'sign-in',
   'buttons_logout': 'logout',
   'buttons_sign_in_fb': 'sign-in with facebook',
   'buttons_sign_in_google': 'sign-in with google',
   'buttons_sign_in_apple': 'sign-in with apple',
  };
  static const pt_br = {
   'buttons_login': 'entrar',
   'buttons_sign_in': 'cadastrar-se',
   'buttons_logout': 'sair',
   'buttons_sign_in_fb': 'entrar com o facebook',
   'buttons_sign_in_google': 'entrar com o google',
   'buttons_sign_in_apple': 'entrar com a  apple',
  };

}

now just add the line in getmaterialapp

    getmaterialapp(
      ...
      translationskeys: apptranslation.translations,
      ...
    )

generate model example

create the json model file in the assets/models/user.json

input:

{
  "name": "",
  "age": 0,
  "friends": ["", ""]
}

run :

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

output:

class user {
  string name;
  int age;
  list<string> friends;

  user({this.name, this.age, this.friends});

  user.fromjson(map<string, dynamic> json) {
    name = json['name'];
    age = json['age'];
    friends = json['friends'].cast<string>();
  }

  map<string, dynamic> tojson() {
    final map<string, dynamic> data = new map<string, dynamic>();
    data['name'] = this.name;
    data['age'] = this.age;
    data['friends'] = this.friends;
    return data;
  }
}

separator file type

one day a user asked me, if it was possible to change what the final name of the file was, he found it more readable to use: my_controller_name.controller.dart, instead of the default generated by the cli: my_controller_name_controller. dart thinking about users like him we added the option for you to choose your own separator, just add this information in your pubsepc.yaml

example:

get_cli:
  separator: "."

are your imports disorganized?

to help you organize your imports a new command was created: get sort, in addition to organizing your imports the command will also format your dart file. thanks to dart_style.
when using get sort all files are renamed, with the separator.
to not rename use the --skiprename flag.

you are one of those who prefer to use relative imports instead of project imports, use the --relative option. get_cli will convert.

internationalization of the cli

cli now has an internationalization system.

to translate the cli into your language:

  1. create a new json file with your language, in the tranlations folder
  2. copy the keys from the file, and translate the values
  3. send your pr.

todo:

  • support for custommodels
  • include unit tests
  • improve generated structure
  • add a backup system

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.