Go to file
2025-05-03 15:35:48 +08:00
android feature: new project 2025-05-03 13:40:41 +08:00
ios feature: 完整诗词应用 2025-05-03 15:33:44 +08:00
lib feature: 完整诗词应用 2025-05-03 15:33:44 +08:00
linux feature: new project 2025-05-03 13:40:41 +08:00
macos feature: 完整诗词应用 2025-05-03 15:33:44 +08:00
test feature: new project 2025-05-03 13:40:41 +08:00
web feature: new project 2025-05-03 13:40:41 +08:00
windows feature: new project 2025-05-03 13:40:41 +08:00
.gitignore feature: new project 2025-05-03 13:40:41 +08:00
.metadata feature: new project 2025-05-03 13:40:41 +08:00
analysis_options.yaml feature: 完整诗词应用 2025-05-03 15:33:44 +08:00
pubspec.lock feature: 完整诗词应用 2025-05-03 15:33:44 +08:00
pubspec.yaml feature: 完整诗词应用 2025-05-03 15:33:44 +08:00
README.md feature: 更新readme 2025-05-03 15:35:48 +08:00

项目目录结构

lib
  - components # 组件
  - helpers
    - constants # 常量
      - api.dart # 请求地址常量
      - index.dart # 常量
      - route.dart # 路由常量
    - config.dart # 环境配置
    - dio.dart # http函数
    - log.dart # 日志函数
  - logics # 逻辑
    - adapters # 数据格式化
    - entities # 数据序列化定义
      - api # 接口字段定义
      - page # 本地字段定义
      - state # 状态字段定义 
    - models # 数据
      - poetry # 请求诗词数据
    - services # 业务逻辑(view-model)
      - poetry_list.dart # 首页数据和逻辑
      - poetry_detail.dart # 诗词详情页数据和逻辑
  - router # 路由配置
    - router.dart 
  - styles # 样式
    - colors # 颜色
    - styles # 文字样式
  - ui # UI界面
    - home.dart # 首页/诗词列表页
    - poetry_detail.dart # 诗词详情页
  - utils # 工具函数
  main.dart # 入口文件

常用命令

# 生成代码
$ dart run build_runner build 
# 运行h5
$ flutter run -d chrome --web-browser-flag "--disable-web-security" --dart-define=APP_ENV=development
# ios生成环境打包
$ flutter build ipa --dart-define=APP_ENV=production
# android生产环境打包
$ flutter build apk --dart-define=APP_ENV=production

package

  1. http请求dio(https://pub.dev/packages/dio/install)

    • 安装:

      $ flutter pub add dio
      
  2. 数据处理freezed(https://pub.dev/packages/freezed)

    • 安装:

      $ flutter pub add freezed_annotation
      $ flutter pub add dev:build_runner
      $ flutter pub add dev:freezed
      $ flutter pub add json_annotation
      $ flutter pub add dev:json_serializable
      
  3. 日志处理使logging(https://pub.dev/packages/logging)

    • 安装:

      $ flutter pub add logging
      
  4. 路由go_router(https://pub.dev/packages/go_router)

    • 安装

      $ flutter pub add go_router
      
  5. 状态管理riverpod(https://pub.dev/packages/riverpod)

    • 安装:

      $ flutter pub add riverpod
      $ flutter pub add flutter_riverpod
      
  6. 微信sdk fluwx(https://pub.dev/packages/fluwx)

    • 安装

      $ flutter pub add fluwx
      
  7. 轻toast fluttertoast(https://pub.dev/packages/fluttertoast)

    • 安装

      $ flutter pub add fluttertoast