getStoredDeviceInfo method
Implementation
@protected
Future<AuthDeviceInfo?> getStoredDeviceInfo([bool generate = true]) async {
try {
final deviceInfoData =
sharedPreferences.getString(AuthSharedPrefKeys.DEVICE_INFO);
AuthDeviceInfo? deviceInfo = deviceInfoData != null
? AuthDeviceInfoModel.fromJson(deviceInfoData)
: null;
if (deviceInfo == null && generate) {
deviceInfo = await AuthDeviceInfoModel.create();
sharedPreferences.setString(
AuthSharedPrefKeys.DEVICE_INFO, deviceInfo.toJson());
}
return deviceInfo;
} catch (e) {
if (generate) {
return await AuthDeviceInfoModel.create();
}
return null;
}
}