flutter_getx_boilerplate
语言:英语(此文件),中文。
简介
在我学习 Flutter 的过程中,我一直在使用 flutter_bloc 状态管理框架。我偶然看到了 GetX 状态管理框架。通过 ReadMe,我发现 GetX 框架非常容易上手。因此,我想在学习的同时写一个 GetX Starter 项目,这不仅可以帮助我自己学习,还可以帮助他人快速构建一个样板项目。在构建这个样板项目之前,我搜索了许多类似的项目,发现它们都相对简单,并且没有一个包含了项目应有的常见功能,因此我萌生了自己写一个想法。下面我将逐一介绍它们。
技术与项目介绍
使用 Flutter 2.x 构建一套包含预定义文件夹结构、风格主题、API 访问、状态管理、路由与依赖等功能的集合。项目结构清晰,可轻松用作 Flutter 模板项目。使用的技术包括但不限于 Flutter、Dart、GetX 等。
安装与使用
步骤 1
将此项目 fork 到您自己的仓库
git clone https://github.com/KevinZhang19870314/flutter_getx_boilerplate.git
步骤 2
使用 VS Code 打开项目文件夹,然后执行以下命令安装依赖包
flutter pub get
步骤 3
打开 lib 文件夹中的 main.dart 文件,按 F5 或 Ctrl + F5 运行项目,然后您就可以开始开发和调试了。
Folder structure
以下是项目文件夹结构(仅介绍 lib 文件夹下的内容)
lib/
|- api - Global Restful api requests, including interceptors, etc.
|- interceptors - Interceptors, including auth, request, and response interceptors.
|- api.dart - Restful api export file.
|- lang - Internationalization, including translation files, translation service files, etc.
|- lang.dart - Language export file.
|- models - Various structured entity classes, divided into request and response entities.
|- models.dart - Entity class export file.
|- modules - Business module folder.
|- auth - Login & Registration Module.
|- home - Home module.
|- splash - Splash module.
|- modules.dart - Module export file.
|- routes - Routing module.
|- app_pages.dart - Routing page configuration.
|- app_routes.dart - Route names.
|- routes.dart - Route export file.
|- Shared - Global shared folders, including static variables, global services, utils, global Widgets, etc.
|- shared.dart - Global shared export file.
|- theme - Theme folder.
|- app_bindings.dart - Services started before the app runs, such as Restful api.
|- di.dart - Global dependency injection objects, such as SharedPreferences, etc.
|- main.dart - Main entry.
其他
在编写过程中,由于涉及 Restful api 的调用,这里我使用了 REQ|RES 提供的免费测试 api。
测试用户如下
email: "[email protected]",
password: "pistol"








