Presentation constructor

Presentation({
  1. String? id,
  2. required List<VerifiablePresentation> verifiablePresentation,
  3. String? goalCode,
  4. String? comment,
  5. String? replyUrl,
  6. List<String>? replyTo,
  7. String? parentThreadId,
  8. String? threadId,
  9. String? from,
  10. List<String>? to,
  11. DateTime? createdTime,
  12. DateTime? expiresTime,
  13. bool pleaseAck = false,
  14. FromPriorJWT? fromPrior,
  15. Map<String, dynamic>? additionalHeaders,
  16. WebRedirect? webRedirect,
  17. ReturnRouteValue? returnRoute,
  18. DidcommMessageTyp? typ,
})

Implementation

Presentation(
    {String? id,
    required this.verifiablePresentation,
    this.goalCode,
    this.comment,
    super.replyUrl,
    super.replyTo,
    super.parentThreadId,
    super.threadId,
    super.from,
    List<String>? super.to,
    super.createdTime,
    super.expiresTime,
    super.pleaseAck,
    super.fromPrior,
    super.additionalHeaders,
    super.webRedirect,
    super.returnRoute,
    super.typ})
    : super(
          id: id ?? Uuid().v4(),
          type: DidcommMessages.presentation,
          body: {}) {
  if (goalCode != null) body['goal_code'] = goalCode;
  if (comment != null) body['comment'] = comment;
  attachments = [];
  for (var d in verifiablePresentation) {
    if (d.presentationSubmission == null) {
      throw Exception(
          'The verifiable Presentation used here must contain a presentation submission');
    }
    var attachment = Attachment(
        data: AttachmentData(json: d.toJson()),
        id: Uuid().v4(),
        format: AttachmentFormat.presentationSubmission2,
        mediaType: 'application/json');
    attachments!.add(attachment);
  }
}