dvOutcomeFromJson function

DVRemoteOutcome dvOutcomeFromJson(
  1. Map<String, Object?> json
)

An outcome as it arrived back on the device.

Implementation

DVRemoteOutcome dvOutcomeFromJson(Map<String, Object?> json) {
  final Object? rejection = json['rejection'];
  if (rejection is String) return DVRemoteOutcome.rejected(rejection);
  final Object? record = json['record'];
  return DVRemoteOutcome.applied(
    record is Map<Object?, Object?>
        ? DVRecord(
            key: record['key'] as Object,
            version: (record['version'] as num).toInt(),
            values: (record['values'] as Map<Object?, Object?>? ??
                    const <Object?, Object?>{})
                .map((Object? k, Object? v) =>
                    MapEntry<String, Object?>('$k', v)),
          )
        : null,
    discarded: json['discarded'] == true,
  );
}