import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; Map _readAndroidBuildData(AndroidDeviceInfo build) { return { '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 _readIosDeviceInfo(IosDeviceInfo data) { return { '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 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; }