Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8b9a090e0 | ||
|
|
c4adbd0665 | ||
|
|
66c03ee245 | ||
|
|
a3ac007759 | ||
|
|
525f58c150 | ||
|
|
0a02620564 | ||
|
|
78a33cd4f1 | ||
|
|
e8610b7aed |
No files matched your search
@@ -1,5 +1,7 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import 'dev_config.dart';
|
import 'dev_config.dart';
|
||||||
import 'prod_config.dart';
|
import 'prod_config.dart';
|
||||||
|
|
||||||
@@ -9,12 +11,10 @@ import 'prod_config.dart';
|
|||||||
/// - `dev_config.dart`:[DevConfig](本机联调)
|
/// - `dev_config.dart`:[DevConfig](本机联调)
|
||||||
/// - `prod_config.dart`:[ProdConfig](生产)
|
/// - `prod_config.dart`:[ProdConfig](生产)
|
||||||
///
|
///
|
||||||
/// 切换环境只改下面这一个布尔值,不用传任何构建参数、也不做网络探测。
|
/// Debug 使用开发环境,Release 自动使用生产环境,不做网络探测。
|
||||||
abstract final class AppConfig {
|
abstract final class AppConfig {
|
||||||
/// **环境开关**:true 用开发环境,false 用生产环境。
|
/// **环境开关**:Debug 使用开发环境,Release 使用生产环境。
|
||||||
///
|
static const bool useDevConfig = !kReleaseMode;
|
||||||
/// 打生产包前必须改成 false;release 构建若仍为 true 会在启动时直接报错。
|
|
||||||
static const bool useDevConfig = true;
|
|
||||||
|
|
||||||
/// 当前选中的环境地址。
|
/// 当前选中的环境地址。
|
||||||
static String get baseUrl =>
|
static String get baseUrl =>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
// 应用环境选择测试。
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:fruitshorts/core/config/app_config.dart';
|
||||||
|
import 'package:fruitshorts/core/config/dev_config.dart';
|
||||||
|
import 'package:fruitshorts/core/config/prod_config.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('should_use_environment_matching_build_mode', () {
|
||||||
|
expect(AppConfig.useDevConfig, !kReleaseMode);
|
||||||
|
expect(
|
||||||
|
AppConfig.baseUrl,
|
||||||
|
kReleaseMode ? ProdConfig.baseUrl : DevConfig.baseUrl,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in new issue
Block a user