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 打不同环境的包

相关推荐
恋猫de小郭14 小时前
Flutter 开始支持 Jetpack Compose Platform View
android·前端·flutter
SoaringHeart1 天前
Flutter 查缺补漏:@JsonKey 属性全解,让模型层不再被后端字段牵着走
flutter
三少爷的鞋1 天前
Android 架构七条铁律:架构师真正设计的不是代码,而是秩序
android
xiangxiongfly9151 天前
Android GsonFactory总结
android·gson·gsonfactory
WythePlus1 天前
Android 14 SELinux策略深度解析
android·安全策略·selinux策略
俩个逗号。。1 天前
Kotlin flow 详解
android·开发语言·kotlin
橙光成长1 天前
android-ad-cleaner:android免 Root 批量关闭系统开屏与营销推送
android·1024程序员节
深圳雨林凯AI1 天前
图案裂变的底色衰减:alpha通道、亮度对比与白墨分色的量化拆解
android
mmsx1 天前
Android 模块化收口:能力组合框架、手写 LifecycleOwner 与热修复共存
android
恋猫de小郭2 天前
Flutter 可以更直接地调用原生 API 了,Dart Direct Native Interop
android·前端·flutter