Flutter 生产样板 Riverpod
一个包含 riverpod、flutter_lints、hive、easy_translations 等的 flutter 项目!
此存储库是我个人项目的起点。如果您有任何建议或改进,请随时告诉我。该项目力求实施 Google 和其他开发人员推荐的最佳实践。这些最佳实践包括但不限于:
- 使用 Riverpod 进行状态管理。
- Using Flutter Lints for stricter linting rules.
- Using Hive for platform independent storage that also works for web.
- 项目结构、const 构造函数、提取的小部件等等…
安装
此存储库要求您的开发环境中安装并配置好 Flutter。
Clone the project and enter the project folder.
git clone https://github.com/anfeichtinger/flutter_production_boilerplate_riverpod.git
cd flutter_production_boilerplate_riverpod
您可以删除位于 assets/img/ 中的屏幕截图。
Get the dependencies.
flutter pub get
Run the app via command line or through your development environment. (optional)
flutter run lib/main.dart
Pub packages
此存储库使用了以下 pub 包
| 包 | 版本 | 用法 |
|---|---|---|
| Riverpod | ^1.0.4 | State management* |
| Flutter Lints | ^2.0.1 | Stricter linting rules |
| Path Provider | ^2.0.10 | Get the save path for Hive |
| Flutter Displaymode | ^0.4.0 | Support high refresh rate displays |
| Easy Localization | ^3.0.1 | Makes localization easy |
| Hive | ^2.2.1 | Platform independent storage. |
| Url Launcher | ^6.1.2 | Open urls in Browser |
| Ionicons | ^0.1.2 | Modern icon library |
* Recommended to keep regardless of your project
Using this package as a starting point
遵循安装步骤后,您可以自定义您的项目。项目中的屏幕和小部件可以轻松替换或删除。它们旨在为用户提供对小部件之间关系的基本理解以及一些良好实践。代码包含一些带有文档和示例的注释。您可以通过在项目文件中搜索“Example:”来找到示例。
Changing the package and app name
您可以遵循此 Stackoverflow 帖子 中的说明。
主题
您可以在 lib/config/theme.dart 文件中自定义您的品牌颜色。该项目使用来自 TailwindCSS 的颜色。主色调使用了靛蓝色调色板,而文本颜色使用了灰色调色板。您可以随时用自己的值替换这些值。为了使文本颜色过渡平滑,有必要覆盖 TextTheme 中的每种文本类型。
Removing unwanted packages
如果某个包未列出,那么将其从 pubspec.yaml 中删除,以及删除所有导入和使用应该就足够了。这是删除所有包所必需的,以下说明是对此的补充。
Flutter Lints
删除 analysis_options.yaml 文件。作为替代,您可以修改此文件中的规则或使用其他包,例如 Lint。
Easy Localization
删除 assets/translations 文件夹。转到 ios/Runner/Info.plist 并删除以下代码
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>de</string>
</array>
Url Launcher
对于 iOS,转到 ios/Runner/Info.plist 并删除以下代码
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
</array>
对于 Android,您可以参考此 Stackoverflow 帖子 获取更多信息。转到 android/app/src/AndroidManifest.xml 并添加以下代码
<manifest [...]
<application>
[...]
</application
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
</manifest>
截图
浅色主题
| Home Light | Info Light |
|---|---|
![]() |
![]() |
深色主题
| Home Dark German | Info Dark German |
|---|---|
![]() |
![]() |
许可证
MIT



