get_cli安装和使用

get_cli安装和使用

1. 安装

运行命令:

1
flutter pub global activate get_cli
1
2
3
4
5
6
7
8
9
10
11
12
13
C:\Users\x>flutter pub global activate get_cli
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Package get_cli is currently active at version 1.8.4.
Resolving dependencies...
The package get_cli is already activated at newest available version.
To recompile executables, first run `flutter pub global deactivate get_cli`.
Installed executables get and getx.
Warning: Pub installs executables into C:\Users\x\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
A web search for "configure windows path" will show you how.
Activated get_cli 1.8.4.

Windows:将 C:\Users\x\AppData\Local\Pub\Cache\bin 添加进环境变量 Path里

2. 验证安装

1
2
3
4
5
6
7
8
9
10
11
C:\Users\x>get -v
░██████╗░███████╗████████╗   ░█████╗░██╗░░░░░░██╗
██╔════╝░██╔════╝╚══██╔══╝   ██╔══██╗██║░░░░░░██║
██║░░██╗░█████╗░░░░░██║░░░   ██║░░╚═╝██║░░░░░░██║
██║░░╚██╗██╔══╝░░░░░██║░░░   ██║░░██╗██║░░░░░░██║
╚██████╔╝███████╗░░░██║░░░   ╚█████╔╝███████╗ ██║
░╚═════╝░╚══════╝░░░╚═╝░░░   ░╚════╝░╚══════╝ ╚═╝

Version: 1.8.4

Time: 66 Milliseconds

3. 使用

功能 命令 备注
新建项目 get create project 新建一个项目,执行期间会选择几个属性,一路下去就行了
初始化 get init 新建项目里也会执行这步,清空lib文件夹内容,填充为初始的目录结构
创建页面 get create page:页面名字 会创建view, controller ,binding 和 routes
创建控制器 get create controller:test 指定文件夹不用写完整路径末级名字就行
创建控制器 get create controller:auth 用模版或者url创建控制器
创建view get create view:name 创建view
国际化 get generate locales assets/locales 需要在指定目录创建对应json文件
创建实体类 get generate model on home with assets/models/user.json 需要在指定目录创建对应json文件

其他命令可参考官方文档: get_cli中文官方文档


get_cli安装和使用
https://jhyjhy.cn/posts/40222/
作者
jhy
发布于
2025年5月29日
许可协议