DeviceContext.fromJson constructor

DeviceContext.fromJson(
  1. Map<String, dynamic> json
)

Accepts both validator keys (os, osVersion) and native keys (operating_system, os_version).

Implementation

factory DeviceContext.fromJson(Map<String, dynamic> json) {
  final os = json['operating_system'] ?? json['os'];
  final osVersion = json['os_version'] ?? json['osVersion'];
  return DeviceContext(
    device: json['device'] as String?,
    deviceName: json['device_name'] as String?,
    emulator: json['emulator'] as bool?,
    os: os is String ? os : os?.toString(),
    osVersion: osVersion,
    networkConnectionType: json['network_connection_type'] as String?,
    networkConnectionSubtype: json['network_connection_subtype'] as String?,
    userAgent: json['user_agent'] as String?,
  );
}