69 lines
2.2 KiB
Dart
69 lines
2.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:device_info_plus/device_info_plus.dart';
|
|
|
|
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.id,
|
|
'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,
|
|
};
|
|
}
|
|
|
|
Future<String> getDeviceName() async {
|
|
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
|
|
|
String deviceName = 'otherDeviceType';
|
|
|
|
if (Platform.isAndroid) {
|
|
final map = _readAndroidBuildData(await deviceInfoPlugin.androidInfo);
|
|
deviceName = map['brand'] + map['model'];
|
|
}
|
|
if (Platform.isIOS) {
|
|
final map = _readIosDeviceInfo(await deviceInfoPlugin.iosInfo);
|
|
deviceName = map['name'];
|
|
}
|
|
return deviceName;
|
|
}
|