mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-26 18:40:32 +08:00
Use device_info_plus instead of device_info
It now contains the toMap functions, so we can delete a lot of code.
This commit is contained in:
@ -2,8 +2,6 @@ import 'dart:io' show Platform;
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
|
||||||
|
|
||||||
import 'package:gitjournal/app.dart';
|
import 'package:gitjournal/app.dart';
|
||||||
import 'package:gitjournal/error_reporting.dart';
|
import 'package:gitjournal/error_reporting.dart';
|
||||||
import 'package:gitjournal/utils/logger.dart';
|
import 'package:gitjournal/utils/logger.dart';
|
||||||
@ -237,53 +235,3 @@ class AnalyticsRouteObserver extends RouteObserver<PageRoute<dynamic>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should be provided by device_info
|
|
||||||
Map<String, dynamic> readAndroidBuildData(AndroidDeviceInfo build) {
|
|
||||||
return <String, dynamic>{
|
|
||||||
'version.securityPatch': build.version.securityPatch,
|
|
||||||
'version.sdkInt': build.version.sdkInt,
|
|
||||||
'version.release': build.version.release,
|
|
||||||
'version.previewSdkInt': build.version.previewSdkInt,
|
|
||||||
'version.incremental': build.version.incremental,
|
|
||||||
'version.codename': build.version.codename,
|
|
||||||
'version.baseOS': build.version.baseOS,
|
|
||||||
'board': build.board,
|
|
||||||
'bootloader': build.bootloader,
|
|
||||||
'brand': build.brand,
|
|
||||||
'device': build.device,
|
|
||||||
'display': build.display,
|
|
||||||
'fingerprint': build.fingerprint,
|
|
||||||
'hardware': build.hardware,
|
|
||||||
'host': build.host,
|
|
||||||
'id': build.id,
|
|
||||||
'manufacturer': build.manufacturer,
|
|
||||||
'model': build.model,
|
|
||||||
'product': build.product,
|
|
||||||
'supported32BitAbis': build.supported32BitAbis,
|
|
||||||
'supported64BitAbis': build.supported64BitAbis,
|
|
||||||
'supportedAbis': build.supportedAbis,
|
|
||||||
'tags': build.tags,
|
|
||||||
'type': build.type,
|
|
||||||
'isPhysicalDevice': build.isPhysicalDevice,
|
|
||||||
'androidId': build.androidId,
|
|
||||||
'systemFeatures': build.systemFeatures,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> readIosDeviceInfo(IosDeviceInfo data) {
|
|
||||||
return <String, dynamic>{
|
|
||||||
'name': data.name,
|
|
||||||
'systemName': data.systemName,
|
|
||||||
'systemVersion': data.systemVersion,
|
|
||||||
'model': data.model,
|
|
||||||
'localizedModel': data.localizedModel,
|
|
||||||
'identifierForVendor': data.identifierForVendor,
|
|
||||||
'isPhysicalDevice': data.isPhysicalDevice,
|
|
||||||
'utsname.sysname:': data.utsname.sysname,
|
|
||||||
'utsname.nodename:': data.utsname.nodename,
|
|
||||||
'utsname.release:': data.utsname.release,
|
|
||||||
'utsname.version:': data.utsname.version,
|
|
||||||
'utsname.machine:': data.utsname.machine,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
|
||||||
// - https://support.google.com/firebase/answer/7029846?hl=en
|
// - https://support.google.com/firebase/answer/7029846?hl=en
|
||||||
// - https://support.google.com/firebase/answer/6317485?hl=en
|
// - https://support.google.com/firebase/answer/6317485?hl=en
|
||||||
|
@ -4,7 +4,7 @@ import 'dart:io' show Platform;
|
|||||||
import 'package:flutter/foundation.dart' as foundation;
|
import 'package:flutter/foundation.dart' as foundation;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:easy_localization_loader/easy_localization_loader.dart';
|
import 'package:easy_localization_loader/easy_localization_loader.dart';
|
||||||
import 'package:flutter_runtime_env/flutter_runtime_env.dart';
|
import 'package:flutter_runtime_env/flutter_runtime_env.dart';
|
||||||
@ -99,14 +99,15 @@ class JournalApp extends StatefulWidget {
|
|||||||
var deviceInfo = DeviceInfoPlugin();
|
var deviceInfo = DeviceInfoPlugin();
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
var info = await deviceInfo.androidInfo;
|
var info = await deviceInfo.androidInfo;
|
||||||
isPhysicalDevice = info.isPhysicalDevice;
|
isPhysicalDevice =
|
||||||
|
info.isPhysicalDevice == null ? false : info.isPhysicalDevice!;
|
||||||
|
|
||||||
Log.i("Running on Android", props: readAndroidBuildData(info));
|
Log.i("Running on Android", props: info.toMap());
|
||||||
} else if (Platform.isIOS) {
|
} else if (Platform.isIOS) {
|
||||||
var info = await deviceInfo.iosInfo;
|
var info = await deviceInfo.iosInfo;
|
||||||
isPhysicalDevice = info.isPhysicalDevice;
|
isPhysicalDevice = info.isPhysicalDevice;
|
||||||
|
|
||||||
Log.i("Running on ios", props: readIosDeviceInfo(info));
|
Log.i("Running on ios", props: info.toMap());
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.d(e.toString());
|
Log.d(e.toString());
|
||||||
|
@ -3,7 +3,7 @@ import 'dart:io' show Platform;
|
|||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
import 'package:sentry/sentry.dart';
|
import 'package:sentry/sentry.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
@ -6,6 +6,7 @@ import FlutterMacOS
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import connectivity_macos
|
import connectivity_macos
|
||||||
|
import device_info_plus_macos
|
||||||
import package_info
|
import package_info
|
||||||
import package_info_plus_macos
|
import package_info_plus_macos
|
||||||
import path_provider_macos
|
import path_provider_macos
|
||||||
@ -16,6 +17,7 @@ import url_launcher_macos
|
|||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||||
|
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||||
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
||||||
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
|
40
pubspec.lock
40
pubspec.lock
@ -262,20 +262,48 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.3"
|
version: "0.1.3"
|
||||||
device_info:
|
device_info_plus:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: device_info
|
name: device_info_plus
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.0"
|
||||||
device_info_platform_interface:
|
device_info_plus_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: device_info_platform_interface
|
name: device_info_plus_linux
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.1.0"
|
||||||
|
device_info_plus_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_macos
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
device_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
device_info_plus_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
device_info_plus_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_windows
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
diff_match_patch:
|
diff_match_patch:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -27,7 +27,7 @@ dependencies:
|
|||||||
connectivity: ^3.0.3
|
connectivity: ^3.0.3
|
||||||
# cryptography: ^1.4.1
|
# cryptography: ^1.4.1
|
||||||
# cryptography_flutter: ^1.0.0
|
# cryptography_flutter: ^1.0.0
|
||||||
device_info: ^2.0.0
|
device_info_plus: ^2.1.0
|
||||||
dots_indicator: ^2.0.0
|
dots_indicator: ^2.0.0
|
||||||
easy_localization: ^3.0.0
|
easy_localization: ^3.0.0
|
||||||
easy_localization_loader: ^1.0.0
|
easy_localization_loader: ^1.0.0
|
||||||
|
Reference in New Issue
Block a user