clean up
This commit is contained in:
32
lib/helpers/dev_info.dart
Normal file
32
lib/helpers/dev_info.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user