create static method
Asynchronously creates an instance of DeviceInfo by fetching the device and application information.
Supports both Android and iOS platforms.
Implementation
static Future<DeviceInfo> create() async {
var deviceInfo = DeviceInfoPlugin();
var packageInfo = await PackageInfo.fromPlatform();
if (defaultTargetPlatform == TargetPlatform.android) {
var androidInfo = await deviceInfo.androidInfo;
return DeviceInfo(
deviceId: androidInfo.id,
deviceName: androidInfo.device,
deviceBrand: androidInfo.brand,
osVersion: androidInfo.version.release,
manufacturer: androidInfo.manufacturer,
model: androidInfo.model,
appVersionName: packageInfo.version,
appVersionCode: int.parse(packageInfo.buildNumber),
);
} else {
var iOSDeviceInfo = await deviceInfo.iosInfo;
return DeviceInfo(
deviceId: iOSDeviceInfo.identifierForVendor,
deviceName: iOSDeviceInfo.name,
deviceBrand: iOSDeviceInfo.name,
osVersion: iOSDeviceInfo.systemVersion,
manufacturer: iOSDeviceInfo.systemName,
model: iOSDeviceInfo.model,
appVersionName: packageInfo.version,
appVersionCode: int.parse(packageInfo.buildNumber),
);
}
}