PresentationDefinition.fromJson constructor
PresentationDefinition.fromJson(
- dynamic presentationDefinitionJson
Implementation
PresentationDefinition.fromJson(dynamic presentationDefinitionJson) {
var definition = credentialToMap(presentationDefinitionJson);
if (definition.containsKey('presentation_definition')) {
definition = definition['presentation_definition'];
}
if (definition.containsKey('id')) {
id = definition['id'];
} else {
throw FormatException('id property required in presentation definition');
}
if (definition.containsKey('input_descriptors')) {
List tmp = definition['input_descriptors'];
inputDescriptors = [];
if (tmp.isNotEmpty) {
for (var i in tmp) {
inputDescriptors.add(InputDescriptor.fromJson(i));
}
}
} else {
throw FormatException(
'input_descriptors property is required in presentation definition');
}
if (definition.containsKey('name')) name = definition['name'];
if (definition.containsKey('purpose')) purpose = definition['purpose'];
if (definition.containsKey('format')) {
format = FormatProperty.fromJson(definition['format']);
}
if (definition.containsKey('submission_requirements')) {
List tmp = definition['submission_requirements'];
if (tmp.isNotEmpty) {
submissionRequirement = [];
for (var s in tmp) {
submissionRequirement!.add(SubmissionRequirement.fromJson(s));
}
}
}
}