You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.9 KiB
1.9 KiB
请帮我生成一个基于 GetX 最佳实践的 Flutter 应用项目骨架。要求如下:
-
目录结构
- lib/
- main.dart
- app/
- data/
- providers/ # 网络请求、API 客户端(使用 GetConnect)
- repositories/ # Repository 层,封装业务数据源
- services/ # 全局服务(如 ThemeService、AuthService)
- modules/
- home/ # 示例模块
- bindings/ # HomeBinding,注册 Controller、Service
- controllers/ # HomeController
- models/ # HomeModel 数据类
- views/ # HomePage 页面
- home/ # 示例模块
- routes/
- app_routes.dart # 路由常量
- app_pages.dart # GetPage 列表,包括中间件示例
- translations/ # 多语言文件(en_US、zh_CN)和 Translations 实现
- widgets/ # 公共 Widget(Loading、ErrorView)
- utils/ # 日志 Logger、网络拦截器等工具函数
- data/
- lib/
-
main.dart
- 使用 GetMaterialApp
- 配置 initialRoute、getPages、theme、darkTheme、locale、translations
-
依赖注入(Bindings)
- 在 app/modules/**/bindings 中,用 Get.lazyPut、Get.putAsync、Get.create 分别示例单例、异步初始化和工厂模式
-
状态管理
- 在 Controller 中使用 Rx + .obs
- 在视图中用 Obx、GetX、GetBuilder
- 在 Controller 的 onInit、onReady、onClose 中写注释说明生命周期
-
路由管理
- 在 app/routes/app_routes.dart 定义路由名称常量
- 在 app/routes/app_pages.dart 用 GetPage 配置路由、binding
-
架构模式
- 强调 “Repository → Service → Controller → View” 分层
- 各层代码注释职责
- 代码风格统一、注释清晰