如何为 qa/dev/prod 构建不同版本的 Flutter 应用程序? [英] How do I build different versions of my Flutter app for qa/dev/prod?
问题描述
我正在构建一个 Flutter 应用程序,我有针对不同环境(QA、开发、生产等)具有不同值的变量.什么是组织应用的好方法,以便我可以轻松地为 QA、开发、生产和其他环境构建构建?
I am building a Flutter app, and I have variables with different values for different environments (QA, dev, prod, etc). What's a good way to organize my app so I can easily make a build for QA, dev, prod, and other environments?
推荐答案
一种方法:在 lib/
中创建不同的 main_
文件项目目录.
One way to do it: create different main_<environment>.dart
files in the lib/
directory of your project.
每个main_
包含特定于环境的配置/值(例如不同的数据库名称等).每个 main_
然后导入实际的应用程序库并运行应用程序,传入环境的值/配置.
Each main_<environment>.dart
contains the environment-specific configurations/values (such as the different database names, etc). Each main_<environment>.dart
then imports the actual application library and runs the application, passing in the environment's values/configurations.
然后,选择要构建的.dart
文件:flutter run -t lib/main_debug.dart
Then, choose which .dart
file to build: flutter run -t lib/main_debug.dart
这篇关于如何为 qa/dev/prod 构建不同版本的 Flutter 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!