SentryDevice.fromJson constructor

SentryDevice.fromJson(
  1. Map<String, dynamic> data
)

Deserializes a SentryDevice from JSON Map.

Implementation

factory SentryDevice.fromJson(Map<String, dynamic> data) {
  final json = AccessAwareMap(data);
  return SentryDevice(
    name: json['name'],
    family: json['family'],
    model: json['model'],
    modelId: json['model_id'],
    arch: json['arch'],
    batteryLevel:
        (json['battery_level'] is num ? json['battery_level'] as num : null)
            ?.toDouble(),
    orientation: json['orientation'] == 'portrait'
        ? SentryOrientation.portrait
        : json['orientation'] == 'landscape'
            ? SentryOrientation.landscape
            : null,
    manufacturer: json['manufacturer'],
    brand: json['brand'],
    screenHeightPixels: json['screen_height_pixels']?.toInt(),
    screenWidthPixels: json['screen_width_pixels']?.toInt(),
    screenDensity: json['screen_density'],
    screenDpi: json['screen_dpi'],
    online: json['online'],
    charging: json['charging'],
    lowMemory: json['low_memory'],
    simulator: json['simulator'],
    memorySize: json['memory_size'],
    freeMemory: json['free_memory'],
    usableMemory: json['usable_memory'],
    storageSize: json['storage_size'],
    freeStorage: json['free_storage'],
    externalStorageSize: json['external_storage_size'],
    externalFreeStorage: json['external_free_storage'],
    bootTime: json['boot_time'] != null
        ? DateTime.tryParse(json['boot_time'])
        : null,
    processorCount: json['processor_count'],
    cpuDescription: json['cpu_description'],
    processorFrequency: json['processor_frequency'],
    deviceType: json['device_type'],
    batteryStatus: json['battery_status'],
    deviceUniqueIdentifier: json['device_unique_identifier'],
    supportsVibration: json['supports_vibration'],
    supportsAccelerometer: json['supports_accelerometer'],
    supportsGyroscope: json['supports_gyroscope'],
    supportsAudio: json['supports_audio'],
    supportsLocationService: json['supports_location_service'],
    unknown: json.notAccessed(),
  );
}