getDeviceUniqueData method

void getDeviceUniqueData()

Implementation

void getDeviceUniqueData() async {
  try {
    final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    if (kIsWeb) {
      final webInfo = await deviceInfo.webBrowserInfo;
      deviceId.value = webInfo.userAgent ?? 'web-browser';
      deviceModel.value = webInfo.browserName.name;
      osVersion.value = webInfo.platform ?? 'Web';
      platform.value = 'web';
    } else if (GetPlatform.isAndroid) {
      final androidInfo = await deviceInfo.androidInfo;
      deviceId.value = androidInfo.id;
      deviceModel.value = androidInfo.model;
      osVersion.value = androidInfo.version.release;
      platform.value = 'android';
    } else if (GetPlatform.isIOS) {
      final iosInfo = await deviceInfo.iosInfo;
      deviceId.value = iosInfo.identifierForVendor ?? 'ios-device';
      deviceModel.value = iosInfo.utsname.machine;
      osVersion.value = iosInfo.systemVersion;
      platform.value = 'ios';
    }
  } catch (e) {
    debugPrint('Error fetching device data: $e');
  }
}