import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/services.dart';

class DeviceInfo {

  static Future<String> getDeviceId() async {
    DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
    if (Platform.isAndroid) {
      AndroidDeviceInfo deviceInfo = await deviceInfoPlugin.androidInfo;
      return deviceInfo.fingerprint ?? 'android error';
    } else if (Platform.isIOS) {
      IosDeviceInfo? deviceInfo = await deviceInfoPlugin.iosInfo;
      return deviceInfo.identifierForVendor ?? 'ios error';
    } else {
      return 'error';
    }
  }

  static Future<int> getAndroidSdkVersion() async {
    DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
    AndroidDeviceInfo deviceInfo = await deviceInfoPlugin.androidInfo;
    return deviceInfo.version.sdkInt;
  }
}