123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import 'dart:async';
- import 'dart:convert';
- import 'dart:io';
- import 'package:device_info/device_info.dart';
- import 'package:fluro/fluro.dart';
- import 'package:flutter/material.dart';
- import 'package:logger/logger.dart';
- import 'package:package_info/package_info.dart';
- import 'package:permission_handler/permission_handler.dart';
- const bool inProduction = const bool.fromEnvironment("dart.vm.product");
- final logger = Logger();
- final RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();
- class Application {
- static BuildContext? context;
- static FluroRouter? router;
- static Map<int, bool> gameLikes = {};
- static int currentPage = 0;
- static Future<String> getDeviceInfo() async {
- DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
- Map<String, dynamic> infos = {};
- infos['os'] = Platform.isAndroid
- ? 1
- : Platform.isIOS
- ? 2
- : 3;
- PackageInfo packageInfo = await PackageInfo.fromPlatform();
- infos['versionCode'] = packageInfo.buildNumber;
- infos['versionName'] = packageInfo.version;
- if (Platform.isIOS) {
- print('IOS设备:');
- IosDeviceInfo info = await deviceInfo.iosInfo;
- infos['name'] = info.name;
- infos['model'] = info.model;
- infos['identifierForVendor'] = info.identifierForVendor;
- infos['isPhysicalDevice'] = info.isPhysicalDevice;
- infos['systemName'] = info.systemName;
- infos['systemVersion'] = info.systemVersion;
- infos['utsname'] = info.utsname;
- } else if (Platform.isAndroid) {
- print('Android设备');
- AndroidDeviceInfo info = await deviceInfo.androidInfo;
- infos['model'] = info.model;
- infos['isPhysicalDevice'] = info.isPhysicalDevice;
- infos['id'] = info.id;
- infos['type'] = info.type;
- infos['tags'] = info.tags;
- infos['device'] = info.device;
- infos['androidId'] = info.androidId;
- infos['board'] = info.board;
- infos['bootloader'] = info.bootloader;
- infos['brand'] = info.brand;
- infos['display'] = info.display;
- infos['fingerprint'] = info.fingerprint;
- infos['hardware'] = info.hardware;
- infos['manufacturer'] = info.manufacturer;
- infos['product'] = info.product;
- var version = info.version;
- infos['baseOS'] = version.baseOS;
- infos['codename'] = version.codename;
- infos['sdkInt'] = version.sdkInt;
- infos['release'] = version.release;
- }
- return json.encode(infos);
- }
- static Future<bool> requestPermission(Permission permission) async {
- PermissionStatus _permissionStatus = await permission.status;
- if (_permissionStatus != PermissionStatus.granted) {
- // 没有权限,发起请求权限
- _permissionStatus = await permission.request();
- return _permissionStatus == PermissionStatus.granted;
- } else {
- return true;
- }
- }
- }
|