当前位置:网站首页>Flutter multi-channel packaging operation
Flutter multi-channel packaging operation
2022-07-26 13:19:00 【Development_ Li Hang】
Use --dart-define The way to pack
config.dart as follows :
// Environment configuration
class EnvConfig {
final String appTitle;
final String appDomain;
EnvConfig({
required this.appTitle,
required this.appDomain,
});
}
// Obtained configuration information
class Env {
// Get the current environment
static const appEnv = String.fromEnvironment(EnvName.envKey);
// development environment
static final EnvConfig _debugConfig = EnvConfig(
appTitle: "debugTitle",
appDomain: "http://www.debugxxx.com",
);
// Release environment
static final EnvConfig _releaseConfig = EnvConfig(
appTitle: "releaseTitle",
appDomain: "http://www.releasexxx.com",
);
// Test environment
static final EnvConfig _testConfig = EnvConfig(
appTitle: "testTitle",
appDomain: "http://www.testxxx.com",
);
static EnvConfig get envConfig => _getEnvConfig();
// Return the corresponding environment configuration according to different environments
static EnvConfig _getEnvConfig() {
print("========appEnv:::$appEnv=============");
switch (appEnv) {
case EnvName.debug:
return _debugConfig;
case EnvName.release:
return _releaseConfig;
case EnvName.test:
return _testConfig;
default:
return _debugConfig;
}
}
}
// Declared environment
abstract class EnvName {
// Environmental Science key
static const String envKey = "MODE";
// Environmental Science value
static const String debug = "debug";
static const String release = "release";
static const String test = "test";
}
The following is used in the code :
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(Env.envConfig.appTitle),// Show envConfig.appTitle
),
body: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Show envConfig.appDomain
Text(
Env.envConfig.appDomain,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w700),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}The default operation is as follows :

Method 1、 adopt Terminal Command to execute --dart-define
Input flutter run --dart-define=MODE=test, enter ( among flutter run Said to run flutter Program ,--dart-define= It's fixed writing ,NODE=test Corresponding to config.dart Under the EnvName Class envKey = "MODE" and test = "test")
Run the following :Cannot run with sound null safety, because the following dependencies don't support null safety

Empty security is not supported , Add the input code as follows :
flutter run --dart-define=MODE=test --no-sound-null-safety
The successful operation is as follows :


Similarly, the operation Department release The environment is as follows :
Input flutter run --dart-define=MODE=release --no-sound-null-safety enter

This method 1 end .
Method 2、 adopt Edit Configurations
1、 Click here to choose Edit Configurations, Click to enter

2、 Click on + Number

3、 choice flutter
4、 Fill in the following :
Name in order , Startup path , Running args, Finally, click Apply.
5、 There will be one more test, The following options test function

give the result as follows :

To this end .
边栏推荐
- B+ tree index uses (7) matching column prefix, matching value range (19)
- Hcip day 11 comparison (BGP configuration and release)
- Bitwise and how to write SQL
- Kubelet CRI 容器运行时
- 基于Bézier曲线的三维造型与渲染
- HCIP第十一天比较(BGP的配置、发布)
- B+ tree (5) introduction to MyISAM -- MySQL from getting started to mastering (17)
- 【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯
- Student examination system based on C #
- LeetCode 2119. 反转两次的数字
猜你喜欢

【5G】5G中的CU和DU是什么?
![[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication](/img/d4/c677de31f73a0e0a4b8b10b91e984a.png)
[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication

How to face scientific and technological unemployment?
![[flower carving hands-on] fun music visualization series small project (12) -- meter tube fast rhythm light](/img/99/6581b8a576e59a13aa4e977e3a1b70.jpg)
[flower carving hands-on] fun music visualization series small project (12) -- meter tube fast rhythm light

目标检测网络R-CNN 系列

RMII, smii, gmii, rgmii interfaces of Ethernet Driver

基于Locust框架进行文件上传下载性能测试
![[typescript] typescript common types (Part 2)](/img/6b/2ac07f16af044bdfb719753ae241cc.png)
[typescript] typescript common types (Part 2)

PostgreSQL official website download error

SLAM 02.整体框架
随机推荐
Shutter background graying effect, how transparency, gray mask
panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
Leetcode 1523. count odd numbers within the interval
Unicode文件解析方法及存在问题
[5gc] what is 5g slice? How does 5g slice work?
基于ASP.NET的某高校学院档案管理系统
JSON格式执行计划(6)—mysql执行计划(五十二)
Kubernetes flannel: host-gw mode
Kubernetes Flannel:HOST-GW模式
Kubelet CRI 容器运行时
Sword finger offer (21): push in and pop-up sequence of stack
Can I take your subdomain? Exploring Same-Site Attacks in the Modern Web
AI theory knowledge map 1 Foundation
Example of establishing socket communication with Siemens PLC based on C # open TCP communication
被罚“带薪休假”一个月后,谷歌解雇了“爱”上 AI 的他
Probability theory and mathematical statistics
3D modeling and rendering based on B é zier curve
A college archives management system based on asp.net
vector的一些实用操作
pomerium