Commit 949d5b4d authored by 李增强's avatar 李增强

添加设备类型和网络类型

parent 9b962889
...@@ -2,9 +2,11 @@ import 'dart:convert'; ...@@ -2,9 +2,11 @@ import 'dart:convert';
import 'http.dart'; import 'http.dart';
import 'package:crypto/crypto.dart' as crypto; import 'package:crypto/crypto.dart' as crypto;
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
import 'package:connectivity/connectivity.dart';
class Utils { class Utils {
static String channel = ''; static String channel = '';
static String deviceId = '';
static bool isDebug = false; static bool isDebug = false;
static Http _http = Http(scheme: "http", host: "8.135.58.206", port: 8802); static Http _http = Http(scheme: "http", host: "8.135.58.206", port: 8802);
...@@ -40,12 +42,24 @@ class Utils { ...@@ -40,12 +42,24 @@ class Utils {
// 获取网络类型 // 获取网络类型
static Future<String> getNetworkType() async { static Future<String> getNetworkType() async {
return "4G"; var result = await Connectivity().checkConnectivity();
var type = 'none';
if (result == ConnectivityResult.mobile) {
type = 'mobile';
} else if (result == ConnectivityResult.wifi) {
type = 'wifi';
}
return type;
}
// 设置设备ID
static void setDeviceId(String d) {
deviceId = d;
} }
// 获取设备ID // 获取设备ID
static Future<String> getDeviceId() async { static Future<String> getDeviceId() async {
return "3A26610FFE43D5838DDE7A40BA2E3E2C"; return deviceId;
} }
// 获取公共参数 // 获取公共参数
......
...@@ -43,6 +43,34 @@ packages: ...@@ -43,6 +43,34 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.15.0-nullsafety.3"
connectivity:
dependency: "direct dev"
description:
name: connectivity
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
connectivity_for_web:
dependency: transitive
description:
name: connectivity_for_web
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.1+4"
connectivity_macos:
dependency: transitive
description:
name: connectivity_macos
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.0+7"
connectivity_platform_interface:
dependency: transitive
description:
name: connectivity_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.6"
convert: convert:
dependency: transitive dependency: transitive
description: description:
...@@ -74,6 +102,11 @@ packages: ...@@ -74,6 +102,11 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
...@@ -102,6 +135,13 @@ packages: ...@@ -102,6 +135,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0-nullsafety.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
......
...@@ -19,6 +19,7 @@ dependencies: ...@@ -19,6 +19,7 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
connectivity: ^2.0.2
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment