Contexts.fromJson constructor
Contexts.fromJson(
- Map<String, dynamic> data
)
Deserializes Contexts from JSON Map.
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,
culture: data[SentryCulture.type] != null
? SentryCulture.fromJson(Map.from(data[SentryCulture.type]))
: null,
gpu: data[SentryGpu.type] != null
? SentryGpu.fromJson(Map.from(data[SentryGpu.type]))
: null,
trace: data[SentryTraceContext.type] != null
? SentryTraceContext.fromJson(Map.from(data[SentryTraceContext.type]))
: null,
runtimes: data[SentryRuntime.type] != null
? [SentryRuntime.fromJson(Map.from(data[SentryRuntime.type]))]
: null,
response: data[SentryResponse.type] != null
? SentryResponse.fromJson(Map.from(data[SentryResponse.type]))
: null,
feedback: data[SentryFeedback.type] != null
? SentryFeedback.fromJson(Map.from(data[SentryFeedback.type]))
: null,
);
data.keys
.where((key) => !_defaultFields.contains(key) && data[key] != null)
.forEach((key) => contexts[key] = data[key]);
return contexts;
}