# flutter_quick **Repository Path**: gitwdd/flutter_quick ## Basic Information - **Project Name**: flutter_quick - **Description**: flutter前端app的基础框架模板,快速使用。当前demo是健身app的模板 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2025-07-31 - **Last Updated**: 2026-01-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 页面展示: ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_2025-07-31_102026_285.png) ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250731102034_9.png) ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250731102039_10.png) ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250731102043_11.png) ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250731102046_12.png) # Flutter 快速开发框架 一个基于 Flutter 的快速开发框架,提供了完整的项目架构、常用组件和最佳实践。 ## 🚀 特性 - **清晰的项目架构**:采用分层架构,代码组织清晰 - **完整的认证系统**:登录、注册、密码管理等功能 - **网络请求封装**:基于 Dio 的 HTTP 客户端,支持拦截器、错误处理 - **本地存储管理**:基于 SharedPreferences 的存储服务 - **路由管理**:使用 go_router 进行类型安全的路由管理 - **状态管理**:使用 Provider 进行全局状态管理 - **主题管理**:支持亮色/暗色主题切换 - **依赖注入**:使用 GetIt 进行依赖管理 - **常用组件**:加载、空状态、对话框、Toast 等 UI 组件 - **代码生成**:支持 JSON 序列化代码生成 ## 📁 项目结构 ``` lib/ ├── core/ # 核心模块 │ ├── di/ # 依赖注入 │ ├── network/ # 网络请求 │ ├── providers/ # 全局状态管理 │ ├── router/ # 路由管理 │ ├── storage/ # 本地存储 │ └── theme/ # 主题管理 ├── common/ # 通用模块 │ ├── pages/ # 通用页面 │ └── widgets/ # 通用组件 ├── features/ # 功能模块 │ ├── auth/ # 认证模块 │ │ ├── models/ # 数据模型 │ │ ├── pages/ # 页面 │ │ ├── repositories/ # 数据仓库 │ │ └── services/ # 业务服务 │ ├── home/ # 首页模块 │ └── profile/ # 个人资料模块 └── main.dart # 应用入口 ``` ## 🛠️ 技术栈 - **Flutter**: 跨平台 UI 框架 - **Dart**: 编程语言 - **Provider**: 状态管理 - **go_router**: 路由管理 - **Dio**: HTTP 客户端 - **GetIt**: 依赖注入 - **SharedPreferences**: 本地存储 - **json_annotation**: JSON 序列化 - **auto_route**: 路由代码生成 ## 📦 依赖包 ### 主要依赖 - `provider`: 状态管理 - `go_router`: 路由管理 - `dio`: 网络请求 - `get_it`: 依赖注入 - `shared_preferences`: 本地存储 - `json_annotation`: JSON 注解 - `logger`: 日志记录 ### 开发依赖 - `build_runner`: 代码生成 - `json_serializable`: JSON 序列化代码生成 - `flutter_lints`: 代码规范检查 ## 🚀 快速开始 ### 1. 安装依赖 ```bash flutter pub get ``` ### 2. 生成代码 ```bash flutter packages pub run build_runner build ``` ### 3. 运行项目 ```bash flutter run ``` ## 📖 使用指南 ### 网络请求 ```dart // 获取 HTTP 客户端 final httpClient = ServiceLocator.get(); // 发送 GET 请求 final response = await httpClient.get('/api/users'); // 发送 POST 请求 final response = await httpClient.post('/api/login', data: { 'email': 'user@example.com', 'password': 'password', }); ``` ### 本地存储 ```dart // 获取存储服务 final storage = ServiceLocator.get(); // 保存数据 await storage.setString('key', 'value'); await storage.setInt('count', 42); await storage.setBool('isEnabled', true); // 读取数据 final value = await storage.getString('key'); final count = await storage.getInt('count'); final isEnabled = await storage.getBool('isEnabled'); ``` ### 状态管理 ```dart // 在页面中使用 Provider Consumer( builder: (context, appProvider, child) { return Text('用户:${appProvider.userInfo?['name']}'); }, ) // 更新状态 final appProvider = context.read(); appProvider.setThemeMode(ThemeMode.dark); ``` ### 路由导航 ```dart // 导航到指定页面 context.push('/profile'); context.go('/home'); // 替换当前页面 context.pushReplacement('/login'); // 返回上一页 context.pop(); ``` ### 显示 Toast ```dart // 显示不同类型的 Toast ToastHelper.showSuccess(context, '操作成功'); ToastHelper.showError(context, '操作失败'); ToastHelper.showWarning(context, '警告信息'); ToastHelper.showInfo(context, '提示信息'); ``` ### 显示对话框 ```dart // 确认对话框 final confirmed = await DialogHelper.showConfirmDialog( context, title: '确认删除', content: '您确定要删除这个项目吗?', ); // 输入对话框 final result = await DialogHelper.showInputDialog( context, title: '输入名称', fields: [ DialogInputField( label: '项目名称', validator: (value) => value?.isEmpty == true ? '请输入项目名称' : null, ), ], ); ``` ## 🎨 主题定制 框架支持亮色和暗色主题,可以通过 `AppProvider` 进行切换: ```dart // 切换主题 final appProvider = context.read(); appProvider.setThemeMode(ThemeMode.dark); // 暗色主题 appProvider.setThemeMode(ThemeMode.light); // 亮色主题 appProvider.setThemeMode(ThemeMode.system); // 跟随系统 ``` ## 🔧 自定义配置 ### 网络配置 在 `lib/core/network/http_client.dart` 中修改基础 URL 和其他配置: ```dart class HttpClient { static const String baseUrl = 'https://your-api.com/api'; // ... } ``` ### 添加新功能模块 1. 在 `lib/features/` 下创建新的功能目录 2. 按照现有结构创建 `models/`、`pages/`、`services/`、`repositories/` 目录 3. 在 `lib/core/di/service_locator.dart` 中注册新的服务 4. 在 `lib/core/router/app_router.dart` 中添加新的路由 ## 📝 代码规范 项目使用 `flutter_lints` 进行代码规范检查,请确保代码符合 Flutter 官方推荐的编码规范。 ## 🤝 贡献 欢迎提交 Issue 和 Pull Request 来改进这个框架。 ## 📄 许可证 本项目采用 MIT 许可证。 ## 🙏 致谢 感谢所有为这个项目做出贡献的开发者和开源社区。 --- **Happy Coding! 🎉**