flutter 通过打包参数区分来 打内网 外网包

内网

bash 复制代码
# 打包内网环境

flutter build apk --dart-define=is_intranet=true --dart-define=is_managerApp=false 

外网

bash 复制代码
# 打包内网环境

flutter build apk --dart-define=is_intranet=true --dart-define=is_managerApp=false 

env.dart

Dart 复制代码
// main.dart
class EnvironmentConfig {
  // 是否是内网
  static const isIntranet = String.fromEnvironment('is_intranet') == "" ||
      String.fromEnvironment('is_intranet') == "true";
  // 是否是管理app
  static const bool isManagerApp =
      String.fromEnvironment('is_managerApp') == "true";
}

然后代码里面使用 EnvironmentConfig 做api 地址处理

最后执行不同打包shell 打不同环境的包

相关推荐
G_dou_21 小时前
Flutter三方库适配OpenHarmony【countdown_timer】倒计时器项目完整实战
flutter·harmonyos
问心无愧051321 小时前
ctf show web入门111
android·前端·笔记
●VON1 天前
AtomGit Flutter鸿蒙客户端:设置页面
flutter·华为·跨平台·harmonyos·鸿蒙
ha_lydms1 天前
AnalyticDB分区、分布键性能优化
android·大数据·分布式·性能优化·分布式计算·分区·analyticdb
星辰1 天前
Ijkplayer重新编译支持h264裸流
android
测试开发-学习笔记1 天前
Android studio安装
android·ide·android studio
宋拾壹1 天前
同时添加多个类目
android·开发语言·javascript
●VON1 天前
AtomGit Flutter鸿蒙客户端:用户资料
flutter·华为·架构·跨平台·harmonyos·鸿蒙
悟空瞎说1 天前
Flutter 三大主流本地存储全解:SharedPreferences、Hive、SQLite 实战指南
flutter
悟空瞎说1 天前
Flutter Isolate 与 compute 全方位实战指南:后台任务优化,保障 UI 60 帧流畅
flutter