toAttachment method

CubeAttachment toAttachment()

Implementation

CubeAttachment toAttachment() {
  Map<String, dynamic> attachmentAttributes = {};

  for (var attribute in attributes) {
    String name = attribute.name;
    String? stringValue = attribute.value;

    dynamic value;

    switch (name) {
      case 'data':
        if (stringValue != null) {
          value = Uri.decodeComponent(stringValue);
        } else {
          value = null;
        }
        break;
      default:
        value = stringValue;
    }
    attachmentAttributes[name] = value;
  }

  return CubeAttachment.fromJson(attachmentAttributes);
}