getDeviceInfo method
Gets comprehensive device information.
Returns a DeviceInformation object containing all available device information for the current platform.
Implementation
@override
Future<DeviceInformation> getDeviceInfo() async {
final window = web.window;
final screen = window.screen;
final navigator = window.navigator;
// Get user agent info
final userAgent = navigator.userAgent;
// Get screen info
final screenWidth = screen.width;
final screenHeight = screen.height;
final pixelRatio = window.devicePixelRatio;
// Get hardware concurrency (CPU cores)
final hardwareConcurrency = navigator.hardwareConcurrency;
// Detect browser
final browserInfo = _detectBrowser(userAgent);
final deviceInfo = _detectDevice(userAgent);
final sensorInfo = await getSensorInfo();
final networkInfo = await getNetworkInfo();
final batteryInfo = await getBatteryInfo();
return DeviceInformation(
deviceName: browserInfo['name'] ?? 'Web Browser',
manufacturer: deviceInfo['manufacturer'] ?? 'Unknown',
model: deviceInfo['model'] ?? browserInfo['name'] ?? 'Web Browser',
brand: deviceInfo['brand'] ?? browserInfo['name'] ?? 'Web',
operatingSystem: _detectOS(userAgent),
systemVersion: await _getOSVersionAsync(userAgent),
buildNumber: await _getBrowserFullVersionAsync(userAgent),
kernelVersion: _getKernelVersion(userAgent),
processorInfo: await _getProcessorInfoAsync(
userAgent,
hardwareConcurrency,
),
memoryInfo: await _getMemoryInfoAsync(),
displayInfo: DisplayInfo(
screenWidth: screenWidth,
screenHeight: screenHeight,
pixelDensity: pixelRatio,
refreshRate: _getRefreshRate(),
screenSizeInches: _calculateScreenSize(
screenWidth,
screenHeight,
pixelRatio,
),
orientation: screenWidth > screenHeight ? 'landscape' : 'portrait',
isHdr: _checkHdrSupport(),
),
batteryInfo: batteryInfo,
sensorInfo: sensorInfo,
networkInfo: networkInfo,
securityInfo: SecurityInfo(
isDeviceSecure: false,
hasFingerprint: false,
hasFaceUnlock: false,
screenLockEnabled: false,
encryptionStatus: window.location.protocol == 'https:'
? 'encrypted'
: 'unencrypted',
),
);
}