1. 安装get_cli 1.1 命令行安装 1 flutter pub global activate get_cli
1.2 get_cli源代码存在问题 1 2 3 4 Failed to build get_cli:get: AppData/Local/Pub/Cache/hosted/pub.dev/dcli-2.3.0/lib/src/util/wait_for_ex.dart:38:17: Error: Method not found: 'waitFor' . value = cli.waitFor<T>(wrapped); ^^^^^^^
get_cli 源代码存在问题,更换一个源代码的镜像即可解决该问题。
1 flutter pub global activate --source =git https://github.com/inyong1/get_cli.git
1 2 3 4 5 6 7 Building package executables... (6.7s) Built get_cli:get. Installed executables get and getx. Warning: Pub installs executables into C:\Users\Administrator\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 from Git repository "https://github.com/inyong1/get_cli.git".
1.3 配置环境变量 下面路径添加到Path环境变量里面
1 C:\Users\Administrator\AppData\Local\Pub\Cache\bin
2. flutter+Getx 搭建项目架构 2.1 创建项目 android 里面推荐使用 android studio 创建,创建的时候指定好应用包名
2.2 使用get_cli构建项目 2.2.1 输入get init
初始化项目 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 PS D:\code\flutter\xmshop> get init 1) GetX Pattern (by Kauê) 2) CLEAN (by Arktekko) Which architecture do you want to use? [1] 1 1) 是的! 2) 不 你的 lib 文件夹不是空的。你确定要覆盖你的应用吗? 警告:操作不可逆 [1] 1 ✓ 'Package: get 已安装! ✓ 文件: main.dart 创建成功,路径: lib\\main.dart ✓ 文件: home_controller.dart 创建成功,路径: lib\app\modules\home\\controllers\\home_controller.dart ✓ 文件: home_view.dart 创建成功,路径: lib\app\modules\home\\views\\home_view.dart ✓ 文件: home_binding.dart 创建成功,路径: lib\app\modules\home\\bindings\\home_binding.dart ✓ 文件: app_routes.dart 创建成功,路径: lib\\app\\routes\\app_routes.dart ✓ 文件: app_pages.dart 创建成功,路径: lib\\app\\routes\\app_pages.dart ✓ home route 创建成功. ✓ Home page 创建成功. ✓ GetX 结构生成成功。 Running `flutter pub get` … $ flutter pub get Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source! Resolving dependencies... Downloading packages... collection 1.18.0 (1.19.0 available) flutter_lints 3.0.2 (4.0.0 available) + get 4.6.6 leak_tracker 10.0.4 (10.0.5 available) leak_tracker_flutter_testing 3.0.3 (3.0.5 available) lints 3.0.0 (4.0.0 available) material_color_utilities 0.8.0 (0.12.0 available) meta 1.12.0 (1.15.0 available) test_api 0.7.0 (0.7.2 available) vm_service 14.2.1 (14.2.4 available) Changed 1 dependency! 9 packages have newer versions incompatible with dependency constraints. Try `flutter pub outdated` for more information. Time: 218329 Milliseconds
2.2.2 创建 tabs home category service cart user serach 对应的 page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 PS D:\code\flutter\xmshop> get create page:tabs ler.dart ✓ 文件: tabs_view.dart 创建成功,路径: lib\app\modules\tabs\\views\\tabs_view.dart ler.dart ✓ 文件: tabs_binding.dart 创建成功,路径: lib\app\modules\tabs\\bindings\\tabs_binding.dart ✓ tabs route 创建成功. ✓ Tabs page 创建成功. Time: 673 Milliseconds PS D:\code\flutter\xmshop> get create page:category gory_controller.dart ✓ 文件: category_view.dart 创建成功,路径: lib\app\modules\category\\views\\category_view.dart ✓ 文件: category_binding.dart 创建成功,路径: lib\app\modules\category\\bindings\\category_binding.dart ✓ category route 创建成功. ✓ Category page 创建成功. Time: 320 Milliseconds PS D:\code\flutter\xmshop> get create page:give ✓ 文件: give_controller.dart 创建成功,路径: lib\app\modules\give\\controllers\\give_controller.dart ✓ 文件: give_view.dart 创建成功,路径: lib\app\modules\give\\views\\give_view.dart ✓ 文件: give_binding.dart 创建成功,路径: lib\app\modules\give\\bindings\\give_binding.dart ✓ give route 创建成功. ✓ Give page 创建成功. Time: 329 Milliseconds PS D:\code\flutter\xmshop> get create page:cart ✓ 文件: cart_controller.dart 创建成功,路径: lib\app\modules\cart\\controllers\\cart_controller.dart ✓ 文件: cart_view.dart 创建成功,路径: lib\app\modules\cart\\views\\cart_view.dart ✓ 文件: cart_binding.dart 创建成功,路径: lib\app\modules\cart\\bindings\\cart_binding.dart ✓ cart route 创建成功. ✓ Cart page 创建成功. Time: 342 Milliseconds PS D:\code\flutter\xmshop> get create page:user ✓ 文件: user_controller.dart 创建成功,路径: lib\app\modules\user\\controllers\\user_controller.dart ✓ 文件: user_view.dart 创建成功,路径: lib\app\modules\user\\views\\user_view.dart ✓ 文件: user_binding.dart 创建成功,路径: lib\app\modules\user\\bindings\\user_binding.dart ✓ user route 创建成功. ✓ User page 创建成功. Time: 332 Milliseconds