toJson method

Map<String, dynamic> toJson()

Produces a Map that can be serialized to JSON.

Implementation

Map<String, dynamic> toJson() {
  return <String, dynamic>{
    if (name != null) 'name': name,
    if (family != null) 'family': family,
    if (model != null) 'model': model,
    if (modelId != null) 'model_id': modelId,
    if (arch != null) 'arch': arch,
    if (batteryLevel != null) 'battery_level': batteryLevel,
    if (orientation != null) 'orientation': orientation!.name,
    if (manufacturer != null) 'manufacturer': manufacturer,
    if (brand != null) 'brand': brand,
    if (screenWidthPixels != null) 'screen_width_pixels': screenWidthPixels,
    if (screenHeightPixels != null)
      'screen_height_pixels': screenHeightPixels,
    if (screenDensity != null) 'screen_density': screenDensity,
    if (screenDpi != null) 'screen_dpi': screenDpi,
    if (online != null) 'online': online,
    if (charging != null) 'charging': charging,
    if (lowMemory != null) 'low_memory': lowMemory,
    if (simulator != null) 'simulator': simulator,
    if (memorySize != null) 'memory_size': memorySize,
    if (freeMemory != null) 'free_memory': freeMemory,
    if (usableMemory != null) 'usable_memory': usableMemory,
    if (storageSize != null) 'storage_size': storageSize,
    if (freeStorage != null) 'free_storage': freeStorage,
    if (externalStorageSize != null)
      'external_storage_size': externalStorageSize,
    if (externalFreeStorage != null)
      'external_free_storage': externalFreeStorage,
    if (bootTime != null) 'boot_time': bootTime!.toIso8601String(),
    if (processorCount != null) 'processor_count': processorCount,
    if (cpuDescription != null) 'cpu_description': cpuDescription,
    if (processorFrequency != null) 'processor_frequency': processorFrequency,
    if (deviceType != null) 'device_type': deviceType,
    if (batteryStatus != null) 'battery_status': batteryStatus,
    if (deviceUniqueIdentifier != null)
      'device_unique_identifier': deviceUniqueIdentifier,
    if (supportsVibration != null) 'supports_vibration': supportsVibration,
    if (supportsAccelerometer != null)
      'supports_accelerometer': supportsAccelerometer,
    if (supportsGyroscope != null) 'supports_gyroscope': supportsGyroscope,
    if (supportsAudio != null) 'supports_audio': supportsAudio,
    if (supportsLocationService != null)
      'supports_location_service': supportsLocationService,
  };
}