59 lines
1.4 KiB
Dart
59 lines
1.4 KiB
Dart
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import '../network/NetworkConfig.dart';
|
|
|
|
const int Environment_Dev = 1;
|
|
const int Environment_Pre = 2;
|
|
const int Environment_Online = 3;
|
|
|
|
class Global {
|
|
factory Global() => _getInstance();
|
|
|
|
static Global get instance => _getInstance();
|
|
static Global? _instance;
|
|
|
|
Global._internal() {
|
|
// 初始化
|
|
}
|
|
|
|
static Global _getInstance() {
|
|
if (_instance == null) {
|
|
_instance = new Global._internal();
|
|
}
|
|
return _instance!;
|
|
}
|
|
|
|
static const method = MethodChannel('samples.flutter.dev/battery');
|
|
|
|
static bool get isRelease => bool.fromEnvironment("dart.vm.product");
|
|
static String? flatform_name;
|
|
|
|
static Future initialize() async {
|
|
if (!NetworkConfig.isTest) {
|
|
NetworkConfig.BASE_URLS = NetworkConfig.BASE_URLS_AI;
|
|
}
|
|
|
|
// if (Platform.isIOS) {
|
|
// //ios相关代码
|
|
// flatform_name = 'iOS';
|
|
// } else if (Platform.isAndroid) {
|
|
// //android相关代码
|
|
// flatform_name = 'Android';
|
|
// } else if (Platform.isWindows) {
|
|
// //android相关代码
|
|
// flatform_name = 'Windows';
|
|
// }
|
|
// WidgetsFlutterBinding.ensureInitialized(); //不加这个强制横/竖屏会报错
|
|
// SystemChrome.setPreferredOrientations([
|
|
// // 强制竖屏
|
|
// DeviceOrientation.portraitUp,
|
|
// DeviceOrientation.portraitDown
|
|
// ]);
|
|
// Global a = Global.instance;
|
|
}
|
|
}
|