getDeviceDetails function
Implementation
Future<DeviceDetails> getDeviceDetails() async {
final deviceInfo = DeviceInfoPlugin();
final locale = PlatformDispatcher.instance.locale;
final timezone = await FlutterTimezone.getLocalTimezone();
if (Platform.isIOS) {
final iosInfo = await deviceInfo.iosInfo;
return DeviceDetails(
id: iosInfo.identifierForVendor,
model: iosInfo.utsname.machine,
manufacturer: 'Apple',
os: 'iOS',
osVersion: iosInfo.systemVersion,
timezone: timezone,
language: locale.toLanguageTag(),
);
} else if (Platform.isAndroid) {
final androidInfo = await deviceInfo.androidInfo;
return DeviceDetails(
id: androidInfo.id,
model: androidInfo.model,
manufacturer: androidInfo.manufacturer,
os: 'Android',
osVersion: androidInfo.version.release,
timezone: timezone,
language: locale.toLanguageTag(),
);
}
return DeviceDetails();
}