FormData.fromJson constructor

FormData.fromJson(
  1. Map<String, dynamic> json
)

Deserializes json into a FormData Object

Implementation

factory FormData.fromJson(Map<String, dynamic> json) {
  final id = json['id'];
  final name = json['name'];
  final title = json['title'];
  final description = json['description'];
  final fields = (json['fields'] as List?)
          ?.map((json) => GridField.fromJson(json))
          .toList() ??
      [];
  final components = (json['components'] as List?)
      ?.map<FormComponent>(
        (e) => FormComponent.fromJson(e, fields),
      )
      .toList();
  final links = linkMapFromJson(json['_links']);
  final attachmentActions = json['attachmentActions'] != null
      ? Map.fromEntries(
          (json['attachmentActions'] as List).map((entry) {
            final action = AttachmentAction.fromJson(entry);
            return MapEntry(action.attachment, action);
          }).toList(),
        )
      : <Attachment, AttachmentAction>{};
  final properties = json['properties'] != null
      ? FormDataProperties.fromJson(json['properties'])
      : null;
  return FormData(
    id: id,
    name: name,
    title: title,
    description: description,
    components: components,
    fields: fields,
    links: links,
    attachmentActions: attachmentActions,
    properties: properties,
  );
}