Contexts.fromJson constructor
Contexts.fromJson(
- Map<String, dynamic> data
)
Implementation
factory Contexts.fromJson(Map<String, dynamic> data) {
final contexts = Contexts(
device: data[SentryDevice.type] != null
? SentryDevice.fromJson(Map.from(data[SentryDevice.type]))
: null,
operatingSystem: data[SentryOperatingSystem.type] != null
? SentryOperatingSystem.fromJson(
Map.from(data[SentryOperatingSystem.type]))
: null,
app: data[SentryApp.type] != null
? SentryApp.fromJson(Map.from(data[SentryApp.type]))
: null,
browser: data[SentryBrowser.type] != null
? SentryBrowser.fromJson(Map.from(data[SentryBrowser.type]))
: null,
gpu: data[SentryGpu.type] != null
? SentryGpu.fromJson(Map.from(data[SentryGpu.type]))
: null,
runtimes: data[SentryRuntime.type] != null
? [SentryRuntime.fromJson(Map.from(data[SentryRuntime.type]))]
: null,
);
data.keys
.where((key) => !_defaultFields.contains(key) && data[key] != null)
.forEach((key) => contexts[key] = data[key]);
return contexts;
}