import 'package:device_info/device_info.dart';
import 'dart:io' show Platform;

class DevInfo {
  bool isAndroid;
  bool isIOS;
  String deviceID;
  String id;
  String model;

  static DevInfo _instance;

  static Future<DevInfo> getDevInfo() async {
    if (_instance != null) return Future.value(_instance);

    _instance = DevInfo();
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();

    if (Platform.isAndroid) {
      AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
      _instance.deviceID = androidInfo.androidId;
      _instance.id = androidInfo.id;
      _instance.model = androidInfo.model;
    } else if (Platform.isIOS) {
      IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
      _instance.deviceID = iosDeviceInfo.identifierForVendor;
      _instance.id = iosDeviceInfo.utsname.release;
      _instance.model = iosDeviceInfo.model;
    }
    return Future.value(_instance);
  }
}
